java - How to retrieve all entity with different column value? -
in following criteria query
criteria criteria = createlogrecordcriteria(maxid, playerid, playerstatus, usercategory, from, to); criteria.setfirstresult(offset); criteria.setmaxresults(limit); criteria.setprojection(projections.distinct(projections.property("player"))); list lst = criteria.list(); return lst;
i retrieve set of different player
s , need retireve entities different player
value. how can done through criteria
?
believe this query searching for.
for below query:
select t table t t.player in (select distinct t.player table t );
if detachedcriteria feasible option, subcriteria can passed maincriteria written below (provided subcriteria should defined detachedcriteria):
criteria subcriteria = criteria.forclass(table.class); subcriteria.setprojection(projections.distinct(projections.property("player"))); criteria maincriteria = createlogrecordcriteria(maxid, playerid, playerstatus, usercategory, from, to); maincriteria.add(property.forname("t.player").in(subcriteria)); //adding restrictions provided in question. maincriteria.setfirstresult(offset); maincriteria.setmaxresults(limit); list lst = maincriteria.list(); return lst;
if not, have result of 'sub-criteria' , pass same (in form of object[] or collection) parameter
> maincriteria.add(property.forname("t.player").in(result_of_subquery));
hope helps.
Comments
Post a Comment