-->
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.  [ 7 posts ] 
Author Message
 Post subject: what mapping to use for
PostPosted: Thu May 06, 2004 12:51 pm 
Newbie

Joined: Mon May 03, 2004 1:08 am
Posts: 18
Tables
Bid (buyer_id,seller_id, amount, date....)
Person(id, name , ...)

buyer_id and seller_id are references to person

In the Bid class I need to show
Buyername, sellerName , amount and date


How do I map this
thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 07, 2004 3:19 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
une an unmapped getter whitch do buyer.getName()

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 08, 2004 12:04 pm 
Regular
Regular

Joined: Wed May 05, 2004 3:41 pm
Posts: 118
Location: New Jersey,USA
would'nt a <one-to-one> relation for each of the id's solve the problem? You can then access the buyer name by bid.buyer.name etc.

It'll force you to have the Bid object to contain a "Buyer" as well as a "Seller" object of the same type "Person".

Have never tried it but I guess that should work.

-Anand


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 10, 2004 12:04 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
anandbn wrote:
would'nt a <one-to-one> relation for each of the id's solve the problem? You can then access the buyer name by bid.buyer.name etc.

It'll force you to have the Bid object to contain a "Buyer" as well as a "Seller" object of the same type "Person".

A many to one actually. But that was not the asked question.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Can someone show an example mapping?
PostPosted: Tue May 11, 2004 7:07 pm 
Newbie

Joined: Tue Oct 28, 2003 6:00 pm
Posts: 14
I am thinking of using buyer = bid.getBuyer(), and then buyer.getName() and buyer.getEmail(), etc. Can anyone help me to complete the mapping below,


<class name="Bid" table="BID">

<id name="id" type="long" column="ID">
<generator class="sequence">
<param name="sequence">BID_ID_SEQ</param>
</generator>
</id>
<property name="sellerId" column="SELLER_ID"/>
<property name="buyerId" column="BUYER_ID"/>
<property name="....>

<set name="buyer" lazy="true"><one-to-one class="Person"/>......</set>
<set name="seller" lazy="true"><one-to-one class="Person">......</set>
</class>


Top
 Profile  
 
 Post subject: I found the example at chpater 15
PostPosted: Tue May 11, 2004 7:49 pm 
Newbie

Joined: Tue Oct 28, 2003 6:00 pm
Posts: 14
<many-to-one name="buyer" class="Person" key_column="BUYER_ID"/>

I don't know why it's many-to-one not one-to-one though.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 11, 2004 10:19 pm 
Newbie

Joined: Thu May 06, 2004 3:08 pm
Posts: 3
Location: Portland, OR
it's many-to-one because many of the same buyers in the bid table can point to the one and only one person.


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