Hibernate version: Hibernate 3.0.5
In a <join> can you specify the property from the parent table that should be used in the join ? It seems to default to the <id> of the parent table.
Example :
The tables are
Code:
STUFF
------------------
STUFF_ID
STUFF_NAME
STUFF_CAT_ID
------------------
CATEGORY
------------------
CAT_ID
CAT_NAME
------------------
Now I have a class called Stuff :
Code:
class Stuff
{
private Long stuffID;
private String stuffName;
private String categoryName;
}
and in the mapping I have :
Code:
<class name="Stuff" table="STUFF" lazy="false" mutable="true">
<id name="stuffID" column="STUFF_ID"/>
<property name="stuffName" column="STUFF_NAME"/>
<join table="CATEGORY">
<key column="CAT_ID" />
<property name="categoryName" column="CAT_NAME" />
</join>
</class>
This tries to join STUFF.STUFF_ID with CATEGORY.CAT_ID. Is there any way to make it use STUFF.STUFF_CAT_ID instead ?