-->
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.  [ 3 posts ] 
Author Message
 Post subject: Criteria.SetFetchMode and Parent.Parent doesn't work
PostPosted: Tue Dec 06, 2005 5:41 pm 
Newbie

Joined: Sun Sep 18, 2005 4:11 am
Posts: 11
Hi,

I'm trying to use SetFetchMode to construct a query with two joins, which will bring out parent.parent in a self-referencing entity:
Code:
class Organization
{
    private Organization _parent;
    ...
}

parent property is mapped with many-to-one with cascade="none", and class has lazy=true.

I tried the following code, but it didn't work:
Code:
            ICriteria c = session.CreateCriteria(typeof(Organization))
               .Add(new EqExpression("Id", 4))
               .SetFetchMode("Parent", FetchMode.Join)
               .SetFetchMode("Parent.Parent", FetchMode.Join);

The above code can only bring out one join, it seems Parent.Parent does not work.

Any ideas?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 07, 2005 11:37 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
Try:
Code:
            ICriteria c = session.CreateCriteria(typeof(Organization))
               .Add(new EqExpression("Id", 4))
               .SetFetchMode("Parent", FetchMode.Join)
               .CreateCriteria(typeof(Parent))
                   .SetFetchMode("Parent", FetchMode.Join);

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 08, 2005 1:34 am 
Newbie

Joined: Sun Sep 18, 2005 4:11 am
Posts: 11
Thanks for the tip, you meant
Code:
            ICriteria c = session.CreateCriteria(typeof(Organization))
               .Add(new EqExpression("Id", 4))
               .SetFetchMode("Parent", FetchMode.Join)
               .CreateCriteria("Parent")
                   .SetFetchMode("Parent", FetchMode.Join);

right?

I tried this, but it still doesn't work...


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

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.