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.