I'm getting this exception:
Code:
org.hibernate.HibernateException: Don't dereference a collection with cascade="all-delete-orphan": od.domain.Category.childCategories
Hibernate version: 3.0.2
Mapping documents:Code:
<class name="Category" table="categories">
<id name="id" type="long" unsaved-value="null">
<generator class="native" />
</id>
<version name="version" />
<property name="created" type="timestamp" not-null="true" />
<property name="name" />
<many-to-one name="parentCategory" class="Category"
cascade="none" column="parent_id" />
<set name="childCategories" cascade="all-delete-orphan" table="categories" sort="natural">
<key column="parent_id" />
<one-to-many class="Category" />
</set>
</class>
My query is:
"from Category c where c.parentCategory is null"
I put a log.error() statement in my setChildCategories() method, and it's indeed being called twice. Then I intentionally threw an exception the second time it was called, to see what was calling it the second time. My stack trace for this exception begins with:
Code:
exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of od.domain.Category.setChildCategories; nested exception is org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of od.domain.Category.setChildCategories
It seems like CGLIB would check whether the collection it's setting has all-delete-orphan cascade for it? I'm not thinking about something right... someone please help! Thanks.