NHibernate Forge
The official new home for the NHibernate community

Comments: Get unique results from joined queries

Attachments

Page Details

First published by:
Ken Egozi
on 09-12-2008
Last revision by:
Woil
on 09-18-2008
9 people found this article useful.
Comments (6)
History (4)

Get unique results from joined queries

Sort by: Published Date | Most Recent | Most Useful
1 2 Next >
By: Jose Ramirez Posted on 09-16-2008 10:46

<p>Cool!</p>

<p>I didn't know about DistinctRootEntityResultTransformer()</p>

By: Tobin Harris Posted on 09-16-2008 10:49

<p>Great post!</p>

By: canton Posted on 06-12-2009 3:30

Just a minor point to note here.

Using Result Transformer with query cache has to be very careful. Executing 2 identical queries with different result transformer *instances* makes Query Cache not working (as I expected).

IQuery query1 = IQuery.GetCacheEnabledQuery().SetResultTransformer(new DistinctRootEntityResultTransformer()).List();

IQuery query2 = IQuery.GetCacheEnabledQuery().SetResultTransformer(new DistinctRootEntityResultTransformer()).List();

query2 can't use the cache from query1 just because the result transofrmer *instances* are different.

IQuery query3 = IQuery.GetCacheEnabledQuery().SetResultTransformer(CriteriaSpecification.DistinctRootEntity).List();

IQuery query4 = IQuery.GetCacheEnabledQuery().SetResultTransformer(CriteriaSpecification.DistinctRootEntity).List();

query4 will get the result from the cache resulted in query3.

By: jbs Posted on 06-15-2009 16:29

Any idea how one can handle this case with nested objects with join queries where its not the root entity being affected?

e.g.

Person.Business.Addresses  where there are 1+ addresses, I get back dups on the Business.

Any help would be gr8.

Thanks

By: jbs Posted on 06-15-2009 16:30

Sorry, forgot to add....the case of loading is through the Person (and lazy loading turned off)

Powered by Community Server (Commercial Edition), by Telligent Systems