These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: DistinctRootEntityResultTransformer()
PostPosted: Thu Sep 13, 2007 9:40 am 
Newbie

Joined: Thu Sep 13, 2007 9:15 am
Posts: 1
Hi,
I have 2 levels of collections of objects: Network has collection of Device, and Device has collection of Resource.

In the Device.hbm.xml file I specify that Resources (its collection of Resource) has property lazy = true.

In my NHibernate provider I write this method:
(T is for Network)

public IList<T> LoadAllInSeparatedSession(String associationPathLevel1, String associationPathLevel2)
{
ISession separatedSession = NHibernateHelper.GetSeparatedSession();
DetachedCriteria query;

if (!String.IsNullOrEmpty(associationPathLevel2))
{
query = DetachedCriteria.For(typeof (T))
.SetFetchMode(associationPathLevel1, FetchMode.Join)
.SetFetchMode(associationPathLevel1 + "." + associationPathLevel2, FetchMode.Join)
.SetResultTransformer(new DistinctRootEntityResultTransformer());
}
else
{
query = DetachedCriteria.For(typeof (T))
.SetFetchMode(associationPathLevel1, FetchMode.Join)
.SetResultTransformer(new DistinctRootEntityResultTransformer()); // Evita record duplicati
}

IList<T> results = query.GetExecutableCriteria (separatedSession).List<T>();


NHibernateHelper.CloseSeparatedSession(separatedSession);

return results;
}

I realized that the "DistinctRootEntityResultTransformer" is applied only to the first level (root) Network.
How is it possible to apply DistinctRootEntityResultTransformer to the second level too ?

Thank's
bye Andrea


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.