Hi,
I'm trying to map a table to itself so that I have a tree-like model. The table looks like this:
Code:
Category (cat_id int, cat_name varchar, cat_parent_id int)
I tried something like this:
Code:
<many-to-one class="Category" column="cat_parent_id" name="parent" cascade="all" />
<set name="children" cascade="all" inverse="true">
<key column="cat_id" />
<one-to-many class="Category" />
</set>
and I have this in the DB:
Code:
cat_id | cat_name | cat_parent_id
--------+------------+---------------
1 | c1 |
2 | c2 | 1
when I delete the first category its child doesn't get deleted.
So is what I'm trying to do possible?
I thought this was a common problem but I actually couldn't find anything in the documentation or the forums.
10x