Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Map a list/set/array to multiple columns in table

 
Lakshmi Dasari
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to map similar type of columns to one property (or rather in a set or array)?

For Eg:

I have a denormalized table where I store individual tooth information in each column of the table say col_tooth1, col_tooth2, col_tooth3 ...col_tooth32 . Rather than having a one-to-one mapping of a column to a property in the persistent object, I would like to store all the information in an array of length 32.

Is it possible to do this kind of mapping in hibernate. Hibernate Sets/Lists represented multiple rows in a table. Can they be used to represent multiple similar types of columns instead of rows?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but you are going to have to do the work.

Basically you can create your own UserType to do the transforming of the "32" colums into one Collection, and going the other direction when storing your data.

Please read http://www.hibernate.org/hib_docs/v3/reference/en/html/mapping.html#mapping-types-custom

On custom usertypes.

Good Luck and have fun.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic