Querying @ElementCollections
在JPA 2.0中使用到注解 @ElementCollection [code] public class Budget extends IdEntity { @ElementCollection(fetch = FetchType.EAGER) @Column(name = "...
在JPA 2.0中使用到注解 @ElementCollection
[code]
public class Budget extends IdEntity {
@ElementCollection(fetch = FetchType.EAGER)
@Column(name = "projectLeaderIDs")
private List<String> projectLeaderIDs;
}
[/code]
在@ElementCollection的属性中做查询
[code]
String sql = "select count(b) from " + Budget.class.getSimpleName()
+ " b,IN (b.projectLeaderIDs) s where :userID in s";
[/code]
show sql:
[code]
Hibernate:
select
count(budget0_.id) as col_0_0_
from
budget budget0_
inner join
Budget_projectLeaderIDs projectlea1_
on budget0_.id=projectlea1_.Budget_id
where
? in (
projectlea1_.projectLeaderIDs
) limit ?
[/code]
评论交流
暂无评论,欢迎留下你的想法