the example of group by in hibernate |
StringBuffer sql = new StringBuffer("select count(user),org.id from HrUsers user,OrgPerson person,OrgOupersonrelation relation,OrgOu org where user.id = person.id and person.id = relation.Pguid and relation.OuGuid = org.id group by org.id");
StringBuffer sql = new StringBuffer("SELECT position.id,position.positionName, COUNT(person) FROM HrAppliedperson person,HrPosition position WHERE person.AppPosition = position.id and person.State!='已录用' AND person.State!='已放弃' AND person.State!='已报到' GROUP BY position.id,position.positionName");
note:after group by ,please add table.id, otherwise hibernate will create the statement that is select all column from .. where .. group by the column difined by you, so the database will throw exception that describe as "some column must be after group by "
|
the example of group by in hibernate
最新推荐文章于 2025-05-30 15:45:32 发布