I have a table that does a self-join to establish parentage to an arbitary depth:
create table cats (
id int not null primary,
parent_id null refernces cats( id ),
name varchar(255)
)
Child rows refernce their (single) parents in the parent_id column:
insert into cats ( 1, null, 'Parent Cat 1' ) ;
insert into cats ( 2, 1, 'Child of Parent Cat 1' ) ;
insert into cats ( 3, 2, 'Child of Child Cat 2' ) ;
With my current hibernate mapping, children are fetched when their parent cat is fetched, but children's children are not.
Is it possible in hibernate to get the children's children fetched?
Hibernate version: 3.0.5
Hibernate mapping:
The pertinent parts of my mapping are:
<class
name="Cat"
table="cat"
>
<id
name="id"
column="id"
type="java.lang.Long"
unsaved-value="null"
>
<set
name="children"
table="cat"
>
<key
column="parent_id"
>
</key>
<one-to-many
class="Cat"
/>
</class>
|