-->
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 question - createAlias
PostPosted: Fri Aug 06, 2004 10:32 am 
Newbie

Joined: Thu Jul 08, 2004 7:16 am
Posts: 8
Hi all,

I would like to ask, if it is possible to create an alias for an associated class of an associated class :-) Something like this:

Code:

-----------*     1---------*       1---------
| Class A |-------|Class B|---------|Class C|
-----------       ---------         ---------



I would like to retrieve objects of Class A, which satisfy a certain condition. The condition is set upon objects of Class C, which are not directly associated to Class A.
I know from the docs, that you can create aliases to directly associated classes, but what about this case?

Thanks for help.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 06, 2004 2:48 pm 
Expert
Expert

Joined: Sat Jan 17, 2004 2:57 pm
Posts: 329
Location: In the basement in my underwear
What I've found that works is:

Code:
Criteria criteria = session.createCriteria(classA);
criteria = session.createAlias("classBAssociationName", "BAssociationAlias");
criteria = session.createAlias("BAssociationAlias" + "." + "classCAssociationAlias", "CAssociationAlias");


you would then build a criterion using "CAssociationAlias" + "." + "thePropertyYouWant"[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 12, 2004 10:43 am 
Newbie

Joined: Thu Jul 08, 2004 7:16 am
Posts: 8
Thanks VampBoy for your reply.

Haven't been able to test it yet, but I have modified my code according to your advice.


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.