Is it possible to set the Criteria.DISTINCT_ROOT_ENTITY with my EntityManager 
object?

I am having the problem of my HQL query returning duplicate objects. I tried 
the distinct keyword as follows:

select distinct client from ClientVO client " +
  |             "left join fetch client.policies policy " +
  |             "left join fetch client.entityLocations entityLocation " +
  |             "left join fetch entityLocation.locationType locationType " +
  |             "left join fetch entityLocation.location location " +
  |             "left join fetch client.clientMembers clientMember " +
  |             "where (client.id = :id)

But I still get the duplicate object returned. I know it has to do with the 
recursive join I have: "left join fetch client.clientMembers clientMember ". I 
came across this article: http://www.hibernate.org/117.html#A12 that seems to 
identify my problem. I want to be able to try the solution that uses 
Criteria.DISTINCT_ROOT_ENTITY but cannot figure out how to setResultTransformer 
from my EntityManager object.

Another thing that is confusing me is why the distinct keyword does not return 
distinct objects. I understand why in the SQL results there are duplicate 
records returned, but I thought the HQL distinct keyword refers to the objects 
returned, not the sql results.

Any thoughts would be appreciated.




View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4058958#4058958

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4058958
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to