assaf27 wrote:
Do you really need to have this as an association? You can do the JOIN in the query itself... e.g.:
Code:
FROM
A a,
B b
WHERE a.foo = b.bar
I don't know if it's possible to make it a proper association (because entities are identified by their ID -> the primary key). But perhaps using a formula/filter on the collection could work.
I guess you could make it work as a join...I'm also having this issue, and am a bit confused as to why it doesn't work. My mapping looks something like the following:
Code:
<class name="User" table="USER">
<id name="id" column="USER_ID" unsaved-value="null">
<generator class="native" />
</id>
<property name="login" column="LOGIN" type="string" length="48"/>
<property name="objectId" column="OBJECT_ID" type="integer" />
<join table="V_USER" inverse="true" fetch="join">
<key column="OBJECT_ID"
property-ref="objectId"
update="false" />
<property name="ldapId" column="LDAP" type="string" update="false" insert="false" />
</join>
</class>
Even though the property-ref is set, it
always joins on the User entity's primary key, when what it should be doing (if property-ref does what it says on the tin) is joining on the OBJECT_ID column instead.