Ignore Hibernate @Where annotation

后端 未结 5 1834
孤独总比滥情好
孤独总比滥情好 2020-12-17 10:05

I have an Entity which has an association to another Entity annotated with @Where, like so

public class EntityA {

    @OneToMany
    @Where(...)
    private         


        
5条回答
  •  感动是毒
    2020-12-17 10:28

    I know its an old question but in case anyone look for an answer...
    I had the same dilemma, you don't want to mess your code with "is_deleted= false" every where you select,

    simple solution is to use native SQL:

    lst = sessionFactory.getCurrentSession().
    createSQLQuery("select {entb.*}  from EntityB entb where  is_deleted=1")                            
               .addEntity("entb", EntityB.class)
               .list();
    

提交回复
热议问题