-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problem doing join.
PostPosted: Mon Nov 13, 2006 7:37 pm 
Newbie

Joined: Mon Nov 13, 2006 7:27 pm
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.