Hibernate 休眠:@wherejointable以筛选子表
我已经在使用@where子句过滤实体的软删除行。(带有“已删除”标志)。这很有效 现在,我需要筛选一个存储链接项历史记录的链接表。 历史策略只是使用链接表的max id行。 这就是我现在拥有的:Hibernate 休眠:@wherejointable以筛选子表,hibernate,annotations,where-clause,Hibernate,Annotations,Where Clause,我已经在使用@where子句过滤实体的软删除行。(带有“已删除”标志)。这很有效 现在,我需要筛选一个存储链接项历史记录的链接表。 历史策略只是使用链接表的max id行。 这就是我现在拥有的: @Where(clause="deleted = 0" ) EntityA{ @Column(name = "id") Integer id; @Column(name = "deleted") Integer deleted; @OneToMany(mappedBy
@Where(clause="deleted = 0" )
EntityA{
@Column(name = "id")
Integer id;
@Column(name = "deleted")
Integer deleted;
@OneToMany(mappedBy = "a")
List<EntityB> subEntities;
EntityB getCurrentEntityB(){
.. loop in java that return the B with the max(id).
}
}
EntityB{
@Column(name = "id")
Integer id;
@JoinColumn(name = "A_ID")
EntityA a;
}
但是语法不正确,我真的不知道怎么做
要在网上找到这个功能上的大量文档并不是那么容易
有什么帮助吗
J
@Where(clause="deleted = 0" )
EntityA{
...
@OneToOne(mappedBy = "a")
@WhereJoinTable(clause = "id in( select max(id) from entityB where a_id = :id )")
EntityB currentEntityB;
}