-->
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.  [ 3 posts ] 
Author Message
 Post subject: Help! About Hibernate Annotation
PostPosted: Mon Feb 27, 2012 5:13 am 
Newbie

Joined: Mon Feb 27, 2012 5:01 am
Posts: 2
Hi,
I have some trouble in reading the Hibernate Doc(Annotation),English isn't my first language.:(
How convert the hbm.xml to anntation
Code:
public class Form implements Serializable{
   private Integer id;
   
   private String name;
   
   private Map<String,ValueSet> props;
   
   public void addProps(String propertyName,String strVal,Integer intVal,Boolean bulVal){
      
      if(props == null){
         props = new HashMap<String,ValueSet>();
      }
      
      ValueSet v = new ValueSet();
      v.setBulVal(bulVal);
      v.setIntVal(intVal);
      v.setStrVal(strVal);
      
      props.put(propertyName, v);
   }
   
   
   public Form() {
   
   }
//setter&getters...

}


ValueSet
Code:
public class ValueSet {
   private String strVal;
   
   private Integer intVal;

   private Boolean bulVal;
   
   private String propertyType;
//stter&getter...
}


hmb.xml is:
Code:
<!-- DTD.. -->
<hibernate-mapping>
   <class name="demo.Form" table="t_form">
      <id name="id">
         <generator class="native"/>
      </id>
      
      <property name="name"/>
      <map name="props" >
         <key column="fid"/>
         <map-key type="string" column="propertyName"></map-key>
         <composite-element class="demo.ValueSet">
            <property name="strVal" type="string"></property>
            <property name="intVal" type="integer"></property>
            <property name="bulVal" type="boolean"></property>
         </composite-element>
      </map>
   </class>
</hibernate-mapping>


How convert the hbm.xml to anntation? Thanks a lot!


Top
 Profile  
 
 Post subject: Re: Help! About Hibernate Annotation
PostPosted: Mon Feb 27, 2012 12:35 pm 
Newbie

Joined: Wed Nov 02, 2011 10:22 am
Posts: 10
hello

you have an exemple here for map annotation:

http://www.jroller.com/eyallupu/entry/h ... ps_support


Top
 Profile  
 
 Post subject: Re: Help! About Hibernate Annotation
PostPosted: Mon Feb 27, 2012 8:28 pm 
Newbie

Joined: Mon Feb 27, 2012 5:01 am
Posts: 2
hi,palex

I did not want the middle Table,how to do?


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

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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.