Hi ,
I have a HBM file which contains "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.
When I try
person.setChildren(anotherPerson);
Its inserting only to "Person" table and not "Person_children" table.
Please help me in resolving this.
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>
Thanks,
Appasamy