I have a mapping that look something like:
Code:
<hibernate-mapping>
<class name="User" table="PERSONS">
<id name="personID" column="PERSON_ID"/>
<property name="lmsUserName" column="WEB_USERNAME" />
<property name="userName" insert="false" update="false" unique="true">
<formula>
coalesce(lower(WEB_USERNAME), lower(USERNAME))
</formula>
</property>
<join table="APPLICATION_USERS" optional="true">
<key column="PERSON_ID"/>
<property name="sasUserName" column="USERNAME"/>
</join>
</class>
</hibernate-mapping>
The problem is that when I get an object using this query, the following query is created:
Code:
select
userimpl0_.PERSON_ID as PERSON1_2_0_,
userimpl0_.WEB_USERNAME as WEB5_2_0_,
userimpl0_2_.USERNAME as USERNAME4_0_,
coalesce(lower(userimpl0_.WEB_USERNAME), lower(userimpl0_.USERNAME)) as formula0_0_,
from PERSONS userimpl0_
left outer join STUDENTS userimpl0_1_
on userimpl0_.PERSON_ID=userimpl0_1_.PERSON_ID
left outer join APPLICATION_USERS userimpl0_2_
on userimpl0_.PERSON_ID=userimpl0_2_.PERSON_ID
where userimpl0_.PERSON_ID=?
So both WEB_USERNAME and USERNAME are assumed to be in the PERSONS table which is incorrect (on the line with the coalesce function). I've tried prefixing these columns with the table name, but since hibernate uses alias', we can't reference using the table name any more.
Any ideas on how to reference the alias' that hibernate uses?