Hibernate 一对多将检查所有子记录,忽略条件中的where条件

Hibernate 一对多将检查所有子记录,忽略条件中的where条件,hibernate,Hibernate,我在Hibernate中有一个一对多关系。比如说报表和项目表。一个报表有许多项目,项目可以处于活动或非活动状态。我需要获取所有具有活动项目的报表 Class Report{ @OneToMany(mappedby="reports") List<Projects> projList; /*get and set methods */ } Class Project{ @ManyToOne Report repors;

我在Hibernate中有一个一对多关系。比如说报表和项目表。一个报表有许多项目,项目可以处于活动或非活动状态。我需要获取所有具有活动项目的报表

Class Report{
    @OneToMany(mappedby="reports")
    List<Projects> projList;
    /*get and set methods */    
} 

Class Project{        
    @ManyToOne
    Report repors;
    /*get and set methods */        
    /*This is a column which represenst ACTIVE or NOT*/
    private status;
}        
但是,当我执行左外部联接而不是内部联接时,我收到的是正确的结果,即只有活动项目。我不知道为什么

你能给我解释一下它是如何正确的并且在所有情况下都是一致的吗? 或者我应该加载活动项目并获取相应的报告
i、 e.具有项目标准(从子项目到父项目)

使用

@OneToMany(mappedby=“reports”)
@不变的
@其中(子句=“status='ACTIVE'”)
列表活动列表;
此集合必须是只读的,因为您必须确保实体中的一致性,因此必须在
projList
集合中进行修改


关于注释很抱歉,如果出现任何错误,我通常使用xml映射文件。

只缺少一个注释状态数据类型。非常感谢您的重播。如果我这样做,那么我的列表将始终具有活动项目,并且我将无法将该列表用于其他where条件,例如:加载给定报表的所有项目,而不考虑其他条件。我不是说只有此集合。我说你可以有这个和你的原始项目清单。然后,当您需要整个项目列表时,它将可用,并且活动项目列表也可用,但仅用于读取目的。您只能在原始列表中进行修改。
List<Reports> reportsList = Criteria(Reports.class)
      .createAlias("projList","projList",INNER_JOIN)
      .add(Restrictions.eq("projList.status","ACTIVE")).list()
for(Report rep:reportsList){
  rep.getProjList(); 
  //This is returning me all the projects irresective of my criteria for 
 // ACTIVE projects. This is hitting another query to the table with the report id 
 //only but not with the status= ACTIVE.So this is returning me all the Projects.
} 
@OneToMany(mappedby="reports")
@Immutable
@Where(clause="status='ACTIVE'")
List<Projects> activeProjList;