From: Mitchell, S. <Ste...@um...> - 2009-04-20 22:55:58
|
Assume you have two tables: Order and ChangeHistory. Order has a one-to-many relationship with ChangeHistory mapped to order.changeHistory. Order history has an update date. How can I do a select an Order based on a specific Date that the FIRST update occurred? In pseudo code this is what I am trying to do: order.getChangeHistory().get(0).getUpdateDate() = aDate -- OR -- order.getChangeHistory().get(0).getUpdateDate() between startDate and endDate Below would return any change history for a given date, not just the first change. final Criteria criteria = getSession().createCriteria( Order.class ); if ( searchCriteria.getUpdateDate() != null ) { criteria.createCriteria( "changeHistory" ).add( Restrictions.eq( "updateDate", searchCriteria.getUpdateDate() ) ); } How do I only get the OLDEST change for an order that happened on a given date? ------------------------------------------------------------------------------ NOTICE: This electronic mail message and any attached files are confidential. The information is exclusively for the use of the individual or entity intended as the recipient. If you are not the intended recipient, any use, copying, printing, reviewing, retention, disclosure, distribution or forwarding of the message or any attached file is not authorized and is strictly prohibited. If you have received this electronic mail message in error, please advise the sender by reply electronic mail immediately and permanently delete the original transmission, any attachments and any copies of this message from your computer system. Thank you. ============================================================================== |