-->
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: Can two properties of the same class be mapped to rows that
PostPosted: Mon Dec 13, 2004 4:48 am 
Newbie

Joined: Mon Dec 13, 2004 4:37 am
Posts: 8
Hi Guys

I am new to Hibernate and it looks like a great tool.

I have seen in a few places that you can not map two classes to the same set of rows. However can you map two collection properties of one class to overlapping rows. Consider an a Parent class with two properties allChildren of type Child and maleChildren of type Child. The second property is just a subset of the first property. Can I map these as two properties where the second property will have some extra filter condition. Or should I map just the first property and use some other means to find the subset I need.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 13, 2004 4:59 am 
Newbie

Joined: Mon Dec 13, 2004 4:37 am
Posts: 8
I have a similar issue with an association table between two classes. The assocation table holds a bit of extra data so it also appears in the object model as a seperate java class. Consider a schema where A and B are related via an association table Assoc. At the java level it would be good if I could have two properties in A one of type Assoc and one of type B. This involces in mapping both these properties to the same rows in the association table. Is this legal, is there a design pattern to resolve this problem?

I thank you in advance


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 13, 2004 7:23 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
AFAIK you can do this by setting update and insert to false for one of the colections and add an a where clause.

An other, more flexible approach is to have DAO layer (IMHO a good idea anyway) and wirte dedicated finder methods using HQL.

HTH
Ernst


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.