Hibernate version: 2.1.7
Name and version of the database you are using: MySQL
Hi All.
I have two simple Hibernate bean classes: Fault.java and Revision.java
Fault class maps to FAULT table, and Revision class maps to REVISION table.
Fault.java contains these 3 properties:
int id (primary key)
String synopsis (nullable varchar)
Revision revision (not sure if I can do something like this)
Revision.java contains these 2 properties:
int id (primary key)
String title (nullable varchar)
I also have the HBM XML files for these two classes.
Note that 'revision' column in FAULT table references the primary key of REVISION table (IOW, FAULT.revision is a foreign key)
Now, is there an implicit way by which I can run a Hibernate query such as:
" select * from Fault "
and expect the returned Fault objects to contain Revision objects instead of just the reference. In other words, if I do the following:
List list = query.list();
for(Iterator itr = list.iterator(); itr.hasNext(); )
{
Fault fault = (Fault) itr.next();
Revision rev = fault.getRevision(); // ???
}
Would rev be a meaningful object with the values populated from the row refered to based on the foreign key in FAULT table?
If I can do something like this, can someone tell me how should my HBM XML files should look like? I tried using components, one-to-one and sets, but I get a null value everytime.
Thanks.
Kartik
|