-->
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: How to map multiple columns in one table to an array?
PostPosted: Tue Aug 16, 2005 1:50 pm 
Newbie

Joined: Tue May 03, 2005 1:53 am
Posts: 7
I have done a lot of search but can't find anything related to this topic.

Basically my table looks like this:

Code:
id, size1, size2, size3, ...., size18


My class looks like this:

Code:
class SizeSpecs {
   private long id;
   private String[18] sizes
}


How should I map the class to the table? Any help is appreciated!


Top
 Profile  
 
 Post subject: Re: How to map multiple columns in one table to an array?
PostPosted: Wed Aug 17, 2005 5:33 am 
Regular
Regular

Joined: Thu Dec 02, 2004 7:11 am
Posts: 85
wfcheang wrote:
I have done a lot of search but can't find anything related to this topic.

Basically my table looks like this:

Code:
id, size1, size2, size3, ...., size18


My class looks like this:

Code:
class SizeSpecs {
   private long id;
   private String[18] sizes
}


How should I map the class to the table? Any help is appreciated!


Hibernate doesn't support this. You should either manualy support this (by native SQL) or use dynamic model. With dynamic model your class should looks like this:

Code:
class SizeSpecs {
   private long id;
   private Map<String,String> sizes;
}


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 17, 2005 5:44 am 
Regular
Regular

Joined: Thu Dec 02, 2004 7:11 am
Posts: 85
Forget about one more way to support this model - using custom value type.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 17, 2005 11:51 am 
Newbie

Joined: Tue May 03, 2005 1:53 am
Posts: 7
sergeya wrote:
Forget about one more way to support this model - using custom value type.


I am thinking about this too. Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 21, 2005 4:29 am 
Newbie

Joined: Tue May 03, 2005 1:53 am
Posts: 7
Now I have tried to map a group of columns to an integer array by using CompositeUserType. Most of it is pretty straightforward. But my question is if we can find out the total number of columns that are mapped to the UserType. For now, I have to hardcode the array length in the CompositeUserType class. It means I cannot re-use the class when the array size is different. This shouldn't be hard for Hibernate to provide such information. Hibernate can easily know from the mapping file how many columns are mapped to the UserType and provide it to methods like getPropertyNames and getPropertyTypes.


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