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: HELP! How do I map this in my HBM?
PostPosted: Wed Apr 08, 2009 8:12 am 
Newbie

Joined: Fri Apr 03, 2009 9:40 am
Posts: 10
I have two tables, each mapped to a C# class.

Table Person
========
PK - PersonID

Table Supporter
==========
PK - SupporterID
FK - PersonID

I'm trying to set up the mapping of the Person class in the HBM - but I get no success.

I've tried using -

<one-to-one name="Supporter" constrained="true" class="Supporter"/>

I get no data returned i.e the Supporter property of the Person instance is null.

If I run the corresponding SQL -

select supporter.* from person
inner join supporter on person.personid = supporter.personid
where person.personid='46'

then I get a row returned.

What am I doing wrong?

Cheers.

TeaVR


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 08, 2009 8:47 am 
Regular
Regular

Joined: Wed Feb 11, 2009 10:58 am
Posts: 55
I think you don't have a one-to-one relationship.

one-to-one is only a choice between two tables who have the same primary key.
From Supporter you have a many-to-one mapping. Because a Person could be in multiple supporter rows.


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.