-->
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.  [ 1 post ] 
Author Message
 Post subject: Howto: Denormalize a map (or set) into a parents table.
PostPosted: Wed Mar 21, 2007 2:19 pm 
Newbie

Joined: Tue Mar 20, 2007 10:09 pm
Posts: 1
If this is a duplicate, I appologize. My post yesterday seems to have been lost. A search for posts by me shows none.

Hibernate version: 3.1.3
Name and version of the database you are using: Mysql 5.0.4

I'd like to be able to map the following class to the following schema. I realize it is not the standard normalized mapping. It is however the requirement.

Code:
class Parent {
  long id;         // id for hibernate
  long my_id;  // our unique id
  Map<String,String> nameValuePairs;
}


Code:
table: parent
columns: id, my_id, map_key, map_value


Concrete example:
Code:
    Parent  {
      id=1,
      my_id=2,
      nameValuePairs={a:va, b:vb}
    }


would be stored as:
Code:
    id   my_id   map_key   map_value
    1       2       a         va
    1       2       b         vb



We can go through a Set<Map.Entry<String,String>> if necessary.

Thanks

Chris


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.