表t_person对应的po文件是TPerson,里面有个Set集合存放岗位(TPosition),他们有一个中间表t_perpos存放员工表的id和岗位表的id
人和岗位的关系是多对多。一个人可以有多个岗位,一个岗位也可以有多个人
现在我想查询在岗位id为2下的人。
sql可以,
select count(*) from t_person t join t_perpos p where t.person_Id=p.personId and p.positionId='2'
怎么用hql写。
人和岗位的关系是多对多。一个人可以有多个岗位,一个岗位也可以有多个人
现在我想查询在岗位id为2下的人。
sql可以,
select count(*) from t_person t join t_perpos p where t.person_Id=p.personId and p.positionId='2'
怎么用hql写。
是要统计岗位id为2下的人数吗?
还是找具体的人
不用sql语句,用hql怎么写。
在TPerson中的set集合存放的是岗位信息。
为什么硬要用HQL,用SQL很方便就实现了。。
select t.* from t_person t join t_perpos p where t.person_Id=p.personId and p.positionId='2' HQL的话。可以试试 :
from t_person t where t.TPosition.id='2' ==>得到人