java - How can I get a count from a related table in Hibernate -
i have 2 simple pojos placed in many 1 relation
@entity public class meeting { @id @generatedvalue(strategy = generationtype.identity) private int meetingid; private string title; @manytoone private location location; ...
and
@entity public class location { @id @generatedvalue(strategy = generationtype.identity) private int locationid; private string name; ...
i'm wondering need count of meetings inside locationlist below
session session = hibernatehelper.getsessionfactory().opensession(); session.begintransaction(); list<location> locationlist = session.createcriteria(location.class).list();
i've thinked of definig @transient meetingscount inside location pojo don't know how go on in order tell hibernate retrieve me.
i know how information making explicit query not i'm looking for
Comments
Post a Comment