-->
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.  [ 5 posts ] 
Author Message
 Post subject: Map a List to individual columns?
PostPosted: Mon Apr 19, 2004 6:55 am 
Newbie

Joined: Mon Oct 27, 2003 10:14 am
Posts: 6
I was wondering if it is possible to map a Java List to individual columns in a database table.

For example, a Java bean has an 'emails' property as a List, but the database table only has single 'email' and 'alt_email' fields.

Is there a way to do this?

I've looked a bit into using a Custom value type, and this might be a feasible option, but I would rather handle everything within the mapping file if possible.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 19, 2004 6:58 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Take a look at the "dynamic-component" element, it should do exactly what you want. It works basically exactly like a component, with the property being of Map type. Take a look at http://www.hibernate.org/hib_docs/reference/html/or-mapping.html#or-mapping-s1-10 and experiment some.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 19, 2004 7:18 am 
Newbie

Joined: Mon Oct 27, 2003 10:14 am
Posts: 6
Thanks a lot, that looks interesting.

However, on the JavaBean side there are no real distinctions between the items in the List, apart from there order. Therefore, would it be appropriate to leave the public JavaBean property as a List, but have a private Map property using Integers as keys?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 19, 2004 7:36 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Yes, if you really just have a List, mapping a private Map property which somehow delegates to the List is currently the only solution I can think of.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 19, 2004 7:53 am 
Newbie

Joined: Mon Oct 27, 2003 10:14 am
Posts: 6
Great.

Yeah, the system is built to work with different backend configurations. So in some integrations there might be a true one-to-many relationships while on others there might only be individual named fields.

Thanks again for the help.


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