All I am doing is clearing out the collection. I happen to have a table of 2 items. I get the 1st item whose primary key is 1(I added it to the db myself). With the option of delete-orphan, the orphan is not deleted even though I removed the reference from the collection. Once I switch to all-delete-orphan, the below code starts working. Is this a bug?
The table is just a table representing a tree
CAT_ID(PK), name VARCHAR(100), PARENT_CAT_ID(FK to this tables CAT_ID)
thanks for any assistance here,
dean
Hibernate version:
hibernate 2.1
Mapping documents:
Code:
<set
name="childCategories"
table="CHAP4_CATEGORY"
lazy="false"
inverse="true"
cascade="delete-orphan"
sort="unsorted"
>
<key
column="PARENT_CAT_ID"
>
</key>
<one-to-many
class="biz.xsoftware.model.chap4.Category"
/>
</set>
<many-to-one
name="parentCategory"
class="biz.xsoftware.model.chap4.Category"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="PARENT_CAT_ID"
/>
Code between sessionFactory.openSession() and session.close(): Code:
Category computer = (Category)session.load(Category.class, new Long(1));
Set s = computer.getChildCategories();
System.out.println("size="+s.size());
s.clear();
System.out.println("size="+s.size());
Full stack trace of any exception that occurs:Name and version of the database you are using:MySQL
The generated SQL (show_sql=true):Code:
Hibernate: select category0_.CAT_ID as CAT_ID1_, category0_.NAME as NAME1_, category0_.PARENT_CAT_ID as PARENT_C3_1_, category1_.CAT_ID as CAT_ID0_, category1_.NAME as NAME0_, category1_.PARENT_CAT_ID as PARENT_C3_0_ from CHAP4_CATEGORY category0_ left outer join CHAP4_CATEGORY category1_ on category0_.PARENT_CAT_ID=category1_.CAT_ID where category0_.CAT_ID=?
Hibernate: select childcateg0_.PARENT_CAT_ID as PARENT_C3___, childcateg0_.CAT_ID as CAT_ID__, childcateg0_.CAT_ID as CAT_ID0_, childcateg0_.NAME as NAME0_, childcateg0_.PARENT_CAT_ID as PARENT_C3_0_ from CHAP4_CATEGORY childcateg0_ where childcateg0_.PARENT_CAT_ID=?
Hibernate: select childcateg0_.PARENT_CAT_ID as PARENT_C3___, childcateg0_.CAT_ID as CAT_ID__, childcateg0_.CAT_ID as CAT_ID0_, childcateg0_.NAME as NAME0_, childcateg0_.PARENT_CAT_ID as PARENT_C3_0_ from CHAP4_CATEGORY childcateg0_ where childcateg0_.PARENT_CAT_ID=?
size=1
size=0
Debug level Hibernate log excerpt: