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
|