-->
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.  [ 7 posts ] 
Author Message
 Post subject: How to map a collection and a pointer to an element of it
PostPosted: Tue Apr 20, 2004 5:18 am 
Regular
Regular

Joined: Tue Jan 13, 2004 4:57 am
Posts: 83
Is there a way to map a collection and a property which points to an element of that collection (i.e. to have something like "addresses" and "mainAddress" in the same entity)?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 20, 2004 5:37 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Just use a normal Java property which accesses your mapped collection and don't map it at all.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 20, 2004 6:19 am 
Regular
Regular

Joined: Tue Jan 13, 2004 4:57 am
Posts: 83
Uhm. But how to reflect the fact that there is a field in the table which points to the id of the dependent object, which is also included in the collection? It should be mapped, shouldn't it?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 20, 2004 6:22 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Map it as an additional private property, I'd suggest.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 20, 2004 6:23 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Or simply map it as a one-to-one, now that I think of it ...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 20, 2004 12:41 pm 
Regular
Regular

Joined: Tue Jan 13, 2004 4:57 am
Posts: 83
Yes, but wouldn't this create problems with duplicate insertions when persisting the containing entity?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 20, 2004 7:17 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Hibernate resolves something like this, as long as you set up your java object relationships correctly.


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