There is a class which properties are stored in different tables. For example class
User stored in the table
users, and in the table
adresses kept his full address. The table
users has PRIMARY KEY
id, in this table also there is a field
adress_id, and in the table
adresses is a field
id.
User is linked to the
Adress on FOREIGN KEY: users.adress_id on adresses.id.
I try to create such mapping:
Code:
<hibernate-mapping>
<class name="com.User" table="users">
<id name="id".....>
<column name="id" ..../>
</id>
<property name="adressId" ...>
<column name="adress_id"/>
</property>
<join table="adresses" ....>
<key column="id" property-ref="adressId"/>
<property ...../>
</join>
</class>
</hibernate-mapping>
Expecting to receive in quiry
left outer join adresses on users.adress_id = adresses.id, actually Hibernate relates tables using PRIMARY KEY users table:
left outer join adresses on users.id = adresses.id.
Can someone explain why the attribute
property-ref described in the documentation for an element
key don't works in this case?