忽略 Hibernate @Where 注释 [英] Ignore Hibernate @Where annotation
问题描述
我有一个实体,它与另一个用@Where 注释的实体有关联,就像这样
I have an Entity which has an association to another Entity annotated with @Where, like so
public class EntityA {
@OneToMany
@Where(...)
private List<EntityB> entityBList;
}
最近不可避免地发生了,我需要加载不符合@Where 子句的EntityB.我可以删除@Where 注释,但它被大量使用,所以理想情况下我不想这样做.除了手动加载 EntityB 的列表之外,还有其他查询,我有哪些选择?我可以告诉 Hibernate 忽略 @Where 注释吗?
Recently the inevitable has happened, I need to load EntityB's that don't conform to the @Where clause. I could remove the @Where annotation, but it is used a lot, so ideally I don't want to do that. Apart from loading the list of EntityB's manually, with another query, what are my options? Can I tell Hibernate to ignore the @Where annotation?
推荐答案
经过大量研究,这似乎是不可能的.我强烈建议避免使用 @Where,因为很难事先预测您是否需要这些关联.
After lots of research it appears that this is simply impossible. I'd strongly suggest avoiding @Where, as it is hard to predict beforehand if you'll ever need those associations or not.
这篇关于忽略 Hibernate @Where 注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!