-->
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: Ternary relationship HQL question
PostPosted: Thu May 13, 2004 1:41 pm 
Newbie

Joined: Fri Mar 05, 2004 10:41 am
Posts: 12
I have 4 tables A, B, C, and D. D contains PK values of A, B, and C. D does not have its own PK.

My POJO's are: A, B, C, and BC. BC is a composite element of B and C. A contains a bag of BC's.

I need to find a list of BC's that belongs to a particular A and with a particular B value.

Tried the following HQL queries:

select elements(a.BC) from A a, B b where a.id=1 and b.id=1 and b=all elements(a.BC).B -- Oracle error

select elements(a.BC) from A a, B b where a.id=1 and b.id=1 and b=all elements(a.BC.B)-- Hibernate error

Any suggestions?


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 13, 2004 1:49 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
When asking questions, give at least:
the Hibernate version
your mapping documents
the Java code between sessionFactory.openSession() and session.close()
the full stack trace of any exception that occurs
the name and version of the database you are using
a debug level Hibernate log excerpt is also appreciated


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 13, 2004 2:48 pm 
Newbie

Joined: Fri Mar 05, 2004 10:41 am
Posts: 12
delpouve wrote:
When asking questions, give at least:
the Hibernate version
your mapping documents
the Java code between sessionFactory.openSession() and session.close()
the full stack trace of any exception that occurs
the name and version of the database you are using
a debug level Hibernate log excerpt is also appreciated


Well, I am not exactly asking a debugging question. It is more about whether my strategy is right or wrong.


Top
 Profile  
 
 Post subject: Re: Ternary relationship HQL question
PostPosted: Fri May 14, 2004 4:23 am 
Expert
Expert

Joined: Fri Feb 06, 2004 7:49 am
Posts: 255
Location: Moscow, Russia
ericlma wrote:
.... Any suggestions?

suggestions :)
http://forum.hibernate.org/viewtopic.php?t=928990
http://forum.hibernate.org/viewtopic.php?t=930781
Example of ternary relation mapping http://opensource.atlassian.com/projects/hibernate/secure/attachment/10500/IntVersionTest-src.zip


Top
 Profile  
 
 Post subject: Re: Ternary relationship HQL question
PostPosted: Fri May 14, 2004 8:36 am 
Newbie

Joined: Fri Mar 05, 2004 10:41 am
Posts: 12
shl wrote:
suggestions :)


Thanks very much for the links. Your sample code provide an excellent example of a many-to-many relationship. However, it does not solve my problem. Any other suggestions?


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 14, 2004 4:20 pm 
Newbie

Joined: Fri Mar 05, 2004 10:41 am
Posts: 12
I completely changed my mapping strategy. Now I have 4 POJO classes: AClass, BClass, CClass, and DClass, each maps to table A, B, C, and D respectively. DClass has 3 many-to-one associations to AClass, BClass, and CClass. Now to get a List of DClass'es, given an AClazz and BClazz, I just do

from DClass d where d.AClass=AClazz and d.BClass=bClazz

If anyone has a better solution, please let me know. Thanks.


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.