Hi! I have a table "tableA" with a one-to-many association to "tableB", so the "tableA" Java object has a java.util.Set of "tableB" objects.
If I create a new "tableA" object with some "tableB" objects added to it, when I want to save the "tableA" object, it has a null ID as expected (unsaved-value="null"). The problem is that the tablaA.id property of the "tableB" objects is also null, and I get a JDBC error because of that.
If I save a "tableA" object with no "tableB" objects on it, and later I add some "tableB's", then it works OK because now "tableA.id" is not null.
The property mapping files look like this:
table1:
Code:
<set
name="table2"
lazy="true"
inverse="true"
cascade="all-delete-orphan"
sort="unsorted"
>
<key>
<column name="id" />
</key>
<one-to-many
class="my.package.table2"
/>
</set>
table2:
Code:
<many-to-one
name="table1"
class="my.package.table1"
not-null="true"
>
<column name="id" />
</many-to-one>
Is it possible to save a newly created "tableA" object with "tableB" childs at the same time?
Thanks in advance.