Not sure where to begin for creating a Criteria query for this situation. I consulted the documentation but still haven't found a solution.
This is the table structure.
Group has a non-primary foreign key relations to both Vector and Name.
Code:
+---------+
|Vector
|---------
|v_id*
|v_ds
|...
+---------+
|
|
|
^
+---------+
|Group
|+---------+
|g_id*
|v_id (fk)
|n_id (fk)
|...
+---------+
V
|
|
|
+---------+
Name
+---------+
|n_id*
|n_ds
|...
+---------+
A native SQL query already exists for an older application that returns
the desired result:
Code:
select v.v_id
from vector v, group g, name n
where g.n_id = n.n_id
and a.v_id=v.v_id;
My question is how to execute this as a Hibernate Criteria query to return the same result as the Native SQL query?
Useful Information:
Using Hibernate 3.0 w/o annotations and J2SE 1.4
Database: Oracle 10g
Vector.hbm.xml and Name.hbm.xml do not have any mappings to Group. But Group has mappings to both Vector and Name.
Here is a snippet from Group.hbm.xml wrt Name and Vector mappings
Code:
<many-to-one
name="name_ref"
column="n_id"
class="Name"
not-null="true">
</many-to-one>
<many-to-one
name="vector_ref"
column="v_id"
class="Vector"
not-null="false">
</many-to-one>
class Group {
private Integer id;
private Vector vector_ref;
private Name name_ref;
// with appropriate getters/setters
}