-->
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.  [ 3 posts ] 
Author Message
 Post subject: problem with <one-to-many> pls help..
PostPosted: Mon Jan 30, 2006 5:16 pm 
Beginner
Beginner

Joined: Sun Jan 22, 2006 8:47 pm
Posts: 31
Hi,


I have a different situation where I do select not on primary Key..

My mappings file:

<class name="Person" table="person">

<id name="pId" column="p_id" >
<generator class="assigned"/>
</id>

<property name="lastName" column="last_name" type="string" />

<many-to-one name="contactInfo" class="Contact" column="phys_id"/>

</class>


________________


<class name="Contact" table="contact">

<id name="cId" type="int" column="c_id" >
<generator class="assigned"/>
</id>

<property name="physId" column="phys_id" type="int" />

<set name="personSet" lazy="false" table="person" inverse="true">
<key column="pId"/>
<one-to-many class="Person" />

</set>


</class>


My problem is I want to query like:

select con.physId , per.lastName from Contact con , con.personSet per

and i want the hibernate to do join using :

contact.PhysId and person.pId

but hibernate implicitly joins on the two primary keys...How I can force the join on my own specific keys...

I specified the required columns in "column" attribute in<one-to-many > and <many-to-one>,But of no result..

Can anyone pls help me..
Thnx


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 30, 2006 6:33 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Try property-ref attribute.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 31, 2006 11:29 am 
Beginner
Beginner

Joined: Sun Jan 22, 2006 8:47 pm
Posts: 31
I have tried "property-ref " attribute..But hibernate joins on primary key instead of the the property name i specified in <property-ref>
Any ideas why it is doing this way?
Thnx


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

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.