For example:
We are joining Class A and Class B but class A already has a join with Class C which may give us duplicate rows. In cases like these Hibernate has DISTINCT_ROOT_ENTITY for rescue, like below.
@Transactional(readOnly = true)
Check out my site seenuonjava.com for more.
@SuppressWarnings("unchecked")
public List<Group> getGroups (String id) {
logger.info("Id is " + id);
Session session = sessionFactory.getCurrentSession();
List<Group> groups = session.createCriteria(Group.class)
.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)
.add(Restrictions.eq("id", id
.list();
return groups;
}
1 comment:
i without a doubt adore your posting kind, very exciting.
don't give up and keep posting in all honesty , because it simply nicely to follow it.
impatient to browse through a lot more of your current writing, have a good day ;)
Post a Comment