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: mapping a Map<string,string>
PostPosted: Tue Apr 08, 2008 7:00 am 
Newbie

Joined: Tue Apr 08, 2008 6:37 am
Posts: 3
Hi folks,

I have following code:

[code]
@Entity
public class X {

@Id private Long id;

@org.hibernate.annotations.CollectionOfElements
Map<String, String> parameter;

// ... getter and setter
}
[/code]

which results in 2 separate tables if I persist an object of class X: table x just has an id column and x_parameter table has an id reference column to table x as well as the key, value pair.

I understand that in general (if there would be more properties in the class) this is probably a required behavior. But in my case I would like to persist that class into one single table having three columns: id, key, value and the primary key would consist of id, key.

Is it possible? How do I solve that using annotations (JPA or Hibernate)?

thanks


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.