I have 2 simple POJOs placed in a many to one 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 what do I need to do to get the count of meetings inside the locationList below
Session session = HibernateHelper.getSessionFactory().openSession();
session.beginTransaction();
List<Location> locationList = session.createCriteria(Location.class).list();
I've thinked of definig a @Transient meetingsCount inside the Location POJO but I don't know how to go on in order to tell Hibernate to retrieve it for me.
I do know how to get this information by making an explicit query but this is not what I'm looking for