hibernate mapping for list of classes -


I have a class a {a_id, other property list} and square b {b_id, other properties} There are separate tables for B and Mapping tables A_B (a_id, b_id, displayorder). Entries are fixed in the table, we can insert / update / remove from Table A. I try to map it to hibernate using it from the list but it is not inserting any row in A_B. What should be the ideal way to map the landscape up?

  & lt; Class name = "A" table = "A" & gt; & Lt; Id name = "templateKey" column = "templateKey" & gt; & Lt; Generator class = "parent" /> & Lt; / Id & gt; & Lt; Property Name = "id" column = "id" / & gt; & Lt; Property Name = "Name" column = "Name" /> & Lt; List name = "selected column" table = "A_B" & gt; & Lt; Key column = "templateKey" /> & Lt; Index-index column = "display order" /> & Lt; One-to-many classes = "b" /> & Lt; / List & gt; & Lt; / Square & gt; & Lt; Class name = "b" table = "b" & gt; & Lt; Id name = "columnKey" column = "columnKey" & gt; & Lt; Generator class = "parent" /> & Lt; / Id & gt; & Lt; Property Name = "displayName" column = "displayName" /> & Lt; / Square & gt;    

Change your HBM file for A You missed Cascade in the A's HBM file, which I suspect is AB. There is no one involved.

  & lt; Class name = "A" table = "A" & gt; & Lt; Id name = "templateKey" column = "templateKey" & gt; & Lt; Generator class = "parent" /> & Lt; / Id & gt; & Lt; Property Name = "id" column = "id" / & gt; & Lt; Property Name = "Name" column = "Name" /> & Lt; List name = "selected column" table = "A_B" cascade = "all" & gt; & Lt; Key column = "templateKey" /> & Lt; Index-index column = "display order" /> & Lt; One-to-many classes = "b" /> & Lt; / List & gt; & Lt; / Square & gt;    

Comments