Hi all,
We have a really restricted java data model and the
class structure/code should not be changed. Here is the class (i simplified it)
Code:
class Person {
private int id;
private int roleId;
private String roleName;
}
In the DB, There are two tables
Code:
person table ONLY has id and roleId
role table has roleId and roleName.
We will have to load both roleId and roleName into the Person object
And here are the mappings
Code:
<class name="Person" table="person">
<id name="id"/>
<property name="roleId"/>
[b]<how to map roleName ???/>[/b]
</class>
I cannot seem to map the roleName, I have tried using join
Code:
<join table="role" optional="true">
<key property-ref="roleId" column="roleId"/>
<property name="roleName"/>
</join>
but the generated SQL code shows
LEFT OUTER JOIN ON person.id = role.roleId instead of
LEFT OUTER JOIN ON person.roleId = role.roleId which I really want.Property-ref seems to get ignored...Is there any way to get it working?
Zillion thanks in advance!!!!!