I have a single object that maps to two tables.
Object is FeedEntry and the tables are
Persons [id (pk), handle]
and
feedentries [id (pk), firstname -etc, person (fk) ]
Where feedentries.person maps to persons.id
I'm useing Hibernate 3.2
and here is my mapping document
<hibernate-mapping auto-import="true" default-lazy="false">
<class name="gino.domain.FeedEntry" table="feedentries">
<id name="id" column="id">
<generator class="identity"/>
</id>
<property name="feedShortName"/>
<property name="titleGroup"/>
<property name="firstname"/>
<property name="surname"/>
<property name="title"/>
<property name="department"/>
<property name="phone"/>
<property name="externalId"/>
<property name="person" column="person"/>
<!-- join must come after any property-->
<join table="persons">
<key column="id" foreign-key="person" property-ref="person"/>
<property name="handle"/>
</join>
</class>
</hibernate-mapping>
Now the problem is that hibernate always attempts the join on feedentries.id=persons.id. I can easily change the column of persons by setting the column field in the <key/> parameter, but how do I change the the column used by the feedentries table (I stuck foreign-key and property-ref in there while experimenting. They didn't change anything)?
Here is the resulting sql statements
select feedentry0_.id as id0_, feedentry0_.feedShortName as feedShor2_0_, feedentry0_.titleGroup as titleGroup0_, feedentry0_.firstname as firstname0_, feedentry0_.surname as surname0_, feedentry0_.title as title0_, feedentry0_.department as department0_, feedentry0_.phone as phone0_, feedentry0_.externalId as externalId0_, feedentry0_.person as person0_, feedentry0_1_.handle as handle1_ from feedentries feedentry0_, persons feedentry0_1_ where feedentry0_.id=feedentry0_1_.id and feedentry0_.feedShortName=?
thanks,
Patrick
|