-->
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.  [ 2 posts ] 
Author Message
 Post subject: Joining tables with mis-named columns
PostPosted: Wed Oct 27, 2004 6:32 pm 
Newbie

Joined: Fri Oct 08, 2004 3:14 am
Posts: 10
Hibernate version: 2.1.6

Hi there, I'm struggling with joining two tables together in a 1:1 relationship.

Table 1: Member

Column members_Id

shares a close and growing relationship with:

Table 2: Policy

Column: member_id

So the join is on pol.member_id = member.members_id

How do I achieve this? If it's a straightforward member_id column in both tables it's easy. All iterations I've tried with mapping are failing currently.

I've even got the book and it's not really helping in this situation, has helped tremendously I'd recommend to newbies to buy a copy. If I've got a critisism it's that the whole 'legacy' database issue could be discussed in a chapter by itself at the end.


Top
 Profile  
 
 Post subject: Fixed sort of
PostPosted: Thu Oct 28, 2004 2:50 am 
Newbie

Joined: Fri Oct 08, 2004 3:14 am
Posts: 10
This will definately join member to policy but I'm not sure about the reverse!

<class
name="Policy"
table="Policies"
>
</class>

<!-- This ensures that the relationship below can work. -->
<property
name="memberId"
type="int"
column="Member_ID"
not-null="true"
length="11"
insert="false"
update="false"

/>
<many-to-one
name="member"
class="Member"
not-null="true"
column="Member_ID"/>

<class
name="Member"
table="Members"
>

<id
name="membersId"
type="int"
column="Members_ID"
>
<generator class="assigned" />
</id>


<!-- bi-directional one-to-many association to Policies -->
<set name="policies">
<key column="Member_ID"/>
<one-to-many class="Policy"/>
</set>

</class>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.