简体   繁体   中英

Hibernate criteria

I have table "Event" and table "Sessions" and each event has a set of sessions and each session has start date and end date.

Event start date : is the start date of first session of that event Event end Date : is the end date of the last session of that event.

what i want to do is return all the events that have start date with entered filters (start - end) using hibernate.

 Criteria eventCriteria = getSession().createCriteria(Event.class);
 eventSessionCriteria = eventCriteria.createCriteria("sessions");
 eventSessionCriteria.add(Expression.ge("startDateAndTime", start));`
 eventSessionCriteria.add(Expression.lt("startDateAndTime", end));

By the previous code : will return the events that have session has start date within entered interval (start - end) which is wrong

I want to do is return the events that have first session(The session that has min start date between all sessions of the event) started within the interval (start - end)

How can i get min session date By using hibernate ?

Thanks in Advance

startDateAndTime ,并将最大结果数限制为一个?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM