Q.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
should work in most of the cases unless we use pagination on parent entities like setFirstResult
and setMaxResult
. There might be some problem with either JoinType
or FetchMode
.
Wrapping the q.list()
with a Set
will be better alternative irrespective of any fetch modes. Something like
Set<Txn> resutls = new HashSet<Txn>(L));
or if you want to return a list again wrap the set with list
List<Txn> results = new ArrayList<Txn>(new HashSet<Txn>(L));