-->
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: How to map a collection to one column (e.g. comma separated)
PostPosted: Fri Oct 07, 2005 5:54 am 
Newbie

Joined: Fri Oct 07, 2005 5:50 am
Posts: 1
I am using Hibernate 2 with JBoss.
My class Report has got a member "arguments" which is a map of possible report arguments.

Currently it is represented in the DB as a VARCHAR column e.g.:

"name(STRING) code(STRING)" - this represents 2 arguments both with a type string.

I would like to create the same mapping in hibernate, that is when the object is loaded, hibernate would popuplate a Map member variable from the string column.

Is such a mapping actually possible ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 07, 2005 5:58 am 
Beginner
Beginner

Joined: Thu Jan 06, 2005 6:11 am
Posts: 32
Location: Magdeburg, Germany
You would need to write a custom map implementation I think.

But I'd strongly suggest changing this really weird mapping to two tables connected by an 1..n relation...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 07, 2005 7:24 am 
Newbie

Joined: Fri Oct 07, 2005 6:36 am
Posts: 7
Such a mapping would be possible, yes.

I use it in out application quite often as we have a lot of generic code.

All you need to do is implement a UserType. Have a look at the example in the Hibernate reference and at the API doc for the UserType interface.


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.