Hallo,
folgende Situation:
Code:
class Parent {
private Set childs;
}
<hibernate-mapping>
<class name="Parent" table="PARENT">
<id name="uuid" type="string" unsaved-value="null">
<column name="parentUid" length="64" not-null="true" />
<generator class="assigned" />
</id>
<set name="childs" inverse="true" cascade="all">
<key column="parentUid" />
<one-to-many
not-found="ignore"
class="Child" />
</set>
</class>
</hibernate-mapping>
class Child {
private Parent parent;
}
<hibernate-mapping>
<class name="Child" table="CHILD">
<id name="uuid" type="string">
<column name="assignmentUid" length="64" not-null="true" />
<generator class="assigned" />
</id>
<many-to-one name="parent" class="Parent" column="parentUid" not-null="true" />
</class>
</hibernate-mapping>
Funktioniert nur, wenn unsaved-value="null" beim Mapping der Child id nicht gesetzt wird. Ansonsten:
org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
bei folgendem Code :
Parent ist schon persistiert und wurde geladen.
Code:
Child = new Child();
parent.add(child);
session.save(parent);
Warum bekommt man die Exception ? Was bedeutet die Exception ?
Danke, Dirk.
Code: