How to implement the query , *.hbm.xml and java about special one-to-one or one-to-none as the below.
There is Cat, Cat could have one child or none child depending on the Child_id value.
The Database table name : Cat
desc Cat;
Id NUMBER NOT NULL UNIQUE;
Name Varchar2(32) NOT NULL;
Child_id NUMBER;
select * from Cat;
Id Name Child_id
-----------------------------------------------------
1000 Kitty 1001
1001 childKitty 1002
1002 grandchildkitty 1003
1003 kitty3 <null>
2000 Polo 1001
2001 Polo2 <null>
3001 Lina <null>
The Child_id relates with Id
What I want to get is that:
If I query Id:1000 (Kitty) once, the all data related could be returned, which includes childKitty and grandchildkitty.
Does anyone tell me how to implement it?
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:3.0.2
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using: oracle 8.1.7
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: