Category is a self-referencing class with a list<Category> under it. however, there is a subclass LeafCategory extends Category, which could be an item in the list.
for mapping, I have
<class name="model.Category" table="Category">
<id name="objectId" type="int" column="OBJECTID">
<generator class="hilo">
<param name="table">hi_value</par
am>
<param name="column">next_value</
param>
<param name="max_lo">100</param>
</generator>
</id>
<property name="name" column="NAME" not-null="true" />
<property name="ownerId" column="OWNERID" />
<many-to-one name="parentCategory" class="model.Category" column="PARENTCATEGORYID" not-null="true" insert="false" update="false" />
<list name="categories" cascade="all-delete-orphan
">
<key column="PARENTCATEGORYID" not-null="true" />
<list-index column="categoriesIdx"/>
<one-to-many class="model.Category"/>
</list>
<union-subclass name="model.LeafCategory" table="LeafCategory">
</union-subclass>
</class>
I find that I am able to add new Category in its parent's list. but when adding a LeafCategory to the list, I get a
org.hibernate.StaleStateEx
ception: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
I have successfully implemented both self-referencing class, and polymorphic classes. it is only when I mix the two into one, that I get this error.
any experts see what is wrong with my mapping?
Start Free Trial