I have a class user that needs to map its properties to 2 legacy tables. This scenario is well documented and an example exists in the caveatemptor application.
But I experience a problem with an invalid SQL statement generated for joining the 2 tables:
The tables (Oracle - can't be modfied!!) are:
BENUTZER (PERS_LOG:VARCHAR2, PERS_NO:NUMBER, PERS_PW:VARCHAR2) PERS_LOG primary key
PERSON (PERS_NO:NUMBER, PERS_VNA:VARCHAR2, PERS_NNA:VARCHAR2) PERS_NO primary key
These two tables are mapped into a single class using the following mapping definition:
Code:
<class name="SimpleUser" table="BENUTZER">
<id name="login" column="PERS_LOG"></id>
<property name="password" column="PERS_PW" insert="false" update="false"></property>
<join table="PERSON">
<key column="PERS_NO" foreign-key="PERS_NO"/>
<property name="firstName" column="PERS_VNA"></property>
<property name="lastName" column="PERS_NNA"></property>
</join>
</class>
when running a test the following invalid SQL is created:
Code:
select this_.PERS_LOG as PERS1_3_0_, this_.PERS_PW as PERS2_3_0_, this_1_.PERS_VNA as PERS2_4_0_, this_1_.PERS_NNA as PERS3_4_0_ from BENUTZER this_ inner join PERSON this_1_ on this_.PERS_LOG=this_1_.PERS_NO where (1=1)]
As you see it tries to join trough this_.PERS_LOG=this_1_.PERS_NO. The correct condition should be this_.PERS_NO=this_1_.PERS_NO!!
I have tried this with hibernate-core-3.2.3 and the latest 3.2.5 version!
I would be happy if anybody could guide me here!
Thanks Martin