-->
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.  [ 6 posts ] 
Author Message
 Post subject: [hibernate 3.2.4] Crtieria select with Fetching object
PostPosted: Tue Oct 02, 2007 5:04 am 
Beginner
Beginner

Joined: Mon Oct 01, 2007 6:23 am
Posts: 20
helloo,

I have a problem with criteria, Id like to select domain,user and user role .wich is an object into user class
Code:

DetachedCriteria crit = DetachedCriteria.forClass(UserAccess.class)
.createAlias("domain","d")
.createAlias("user", "u")
.setFetchMode("u",FetchMode.SELECT)
.setFetchMode("u.role", FetchMode.SELECT)
.setFetchMode("d", FetchMode.SELECT)         
.add(Restrictions.eq("u.lastname", "caterpillar"))
;


I get user but without user.role object..even all object for domain class are null..

how can I choose classes which I want to feetch there values..

thanks..


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 03, 2007 12:45 pm 
Beginner
Beginner

Joined: Mon Oct 01, 2007 6:23 am
Posts: 20
no body care..??


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 04, 2007 3:29 am 
Regular
Regular

Joined: Sun Sep 30, 2007 7:51 pm
Posts: 93
See this

http://www.hibernate.org/hib_docs/v3/re ... icfetching
http://www.hibernate.org/hib_docs/v3/re ... e-fetching

Maybe use of FetchMode.EAGER (JOIN now)

Pavol


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 05, 2007 9:34 am 
Beginner
Beginner

Joined: Mon Oct 01, 2007 6:23 am
Posts: 20
pavol.zibrita wrote:


FetchMode.EAGER is deprecated!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 05, 2007 9:57 am 
Beginner
Beginner

Joined: Mon Oct 01, 2007 6:23 am
Posts: 20
it seems ok with :

Code:
DetachedCriteria crit = DetachedCriteria.forClass(UserAccess.class)
.createAlias("domain","d")
.createAlias("user", "u")
.setFetchMode("u",FetchMode.SELECT)
.setFetchMode("user.role", FetchMode.JOIN)
.setFetchMode("d", FetchMode.SELECT)         
.add(Restrictions.eq("u.lastname", "caterpillar"))
;


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 05, 2007 10:49 am 
Regular
Regular

Joined: Sun Sep 30, 2007 7:51 pm
Posts: 93
Sorry, I should write FetchMode.JOIN (EAGER before) :-).

Was a little confusing.

Pavol


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.