-->
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: Hibernate Dynamic Model | Not working with Self reference
PostPosted: Wed Jan 02, 2013 5:28 am 
Newbie

Joined: Thu Oct 25, 2012 3:31 am
Posts: 3
Hi All,

I am using hibernate Dynamic models in my project.

It is not working as expected in one of the scenario as explained below:

Entity Structure:
"Person" entity and an attribute named 'Children' (0 to N) in that which is also "Person" entity type.
So a person will have 0 to N children of same Person Type.

HBM Structure:


Code:
<hibernate-mapping auto-import="false">
   <class entity-name="Person" abstract="false" lazy="true" discriminator-value="Person" table="`Person`">

      <id name="id" type="java.lang.String">
         <column not-null="true" unique="false" name="`id`"/>
      </id>
      <property name="name" lazy="false" insert="true" update="true" not-null="false" unique="false" type="java.lang.String">
         <column not-null="false" unique="false" name="`name`"/>
      </property>
      <property name="displayName" lazy="false" insert="true" update="true" not-null="false" unique="false" type="java.lang.String">
         <column not-null="false" unique="false" name="`displayname`"/>
      </property>
     
      <list name="children" table="`person_children`" inverse="true" lazy="extra" cascade="persist,merge,refresh,save-update,lock">
         
         <key update="true">
            <column name="`person_children_id`" unique="false" index="person_children"/>
         </key>
         <list-index column="`person_children_idx`"/>
         <many-to-many entity-name="Person" unique="true" foreign-key="person_children">
            <column name="`person_id`" unique="false" index="person_children"/>
         </many-to-many>
      </list>
   </class>
</hibernate-mapping>




I am passing below HashMap value:


{
id = 1,

name = Person-1,
displayName = Person-1
children = [{
id = 1,
node = null,
name = Children-1,
displayName = Children - 1
}]
}



Its saving only "Person" and not the association table "person_children"

Please let me know if any solution.


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.