Hello Hibernate Geeks!
I have a property I would like to map, and I'm not really sure how to do it (if it is possible).
I want to store JMS properties in a Map<String, Object> field.
As properties are Objects of only specific types (String and primitives) I believe Hibernate should be able to store them properly. Moreover I would like it to be searchable (so no serialized objects used).
I don't care so much about database representation, but I would like the field not to change its type so it should be a map containing Strings and wrapped primitives (no custom entities).
I started with such set of annotations, but it doesn't work
Code:
@ManyToAny(metaColumn=@Column(name="type"))
@JoinTable(name="properties")
@AnyMetaDef(
idType = "integer",
metaType = "string",
metaValues = {
@MetaValue(value="string", targetEntity=String.class),
@MetaValue(value="int", targetEntity=Integer.class)
// another metadata defined here
}
)
@org.hibernate.annotations.MapKey(columns=@Column(name="key"))
private Map<String, Object> properties;
I was also looking at @Any and @CollectionOfElements annotations but failed so far.
Has someone any idea how to solve it?
Thanks,
Roman