-->
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: How to annotate Map<String, Object> property?
PostPosted: Mon Mar 08, 2010 12:48 pm 
Newbie

Joined: Thu Mar 04, 2010 10:35 am
Posts: 1
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


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.