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: Restrictions for class type of associated object
PostPosted: Mon Feb 05, 2007 3:24 pm 
Newbie

Joined: Sun May 28, 2006 1:09 pm
Posts: 2
Suppose example:

B - an abstract class
B1 - a (concrete) subclass of class B
B2 - a subclass of class B

A - class that is asociated with B like this A.getB()


Criteria rootCriteria = session.createCriteria(A.class);
Criteria asociatedCriteria = rootCriteria.createCriteria("B");

Is it possible to query like this?
asociatedCriteria.add(Restrictions.eq("class", B1.class));

How can I reach this polymorphism restriction on associations?

Thanks for your answers, or future soon implementation.

_________________
Best regards,
Andrej Zachar


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 06, 2007 12:04 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
hi azachar

i haven't cross with asociatedCriteria.add(Restrictions.eq("class", B1.class)); type restriction in my hibernate Experience

_________________
Dharmendra Pandey


Top
 Profile  
 
 Post subject: Re: Restrictions for class type of associated object
PostPosted: Thu Feb 08, 2007 9:24 am 
Beginner
Beginner

Joined: Tue Mar 21, 2006 5:49 pm
Posts: 20
azachar wrote:
Suppose example:

B - an abstract class
B1 - a (concrete) subclass of class B
B2 - a subclass of class B

A - class that is asociated with B like this A.getB()


Criteria rootCriteria = session.createCriteria(A.class);
Criteria asociatedCriteria = rootCriteria.createCriteria("B");

Is it possible to query like this?
asociatedCriteria.add(Restrictions.eq("class", B1.class));

How can I reach this polymorphism restriction on associations?

Thanks for your answers, or future soon implementation.



Did you find any solution for this? I need the same thing....

BTJ

_________________
Someone wrote:
"I understand that if you play a Windows CD backwards you hear strange Satanic messages"
To which someone replied:
"It's even worse than that; play it forwards and it installs Windows"


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.