Hi,
I have an Email object, which has a list of Recipient objects and I would like to know how to use criteria queries to match the e-mail address of one of the recipients without getting back duplicate objects.
I have searched around a lot and found the Distinct interface (org.hibernate.criterion.Distinct) which I believe was added in Hibernate 3.0.2 to remedy situations like this, but I cannot figure out how to use it. I can't find any examples of use of this class online.
Please could somebody let me know how to use this Distinct interface for use with the following simple code:
Code:
Criteria crit = this.getSession().createCriteria(Email.class);
Criteria recipCrit = crit.createCriteria("recipients");
recipCrit.add(Restrictions.eq("emailAddress", "email@address.com"));
I
cannot use the following line because I plan to page the results:
Code:
crit.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
Thanks in advance.