-->
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: Question about the example provided (AutionItem)
PostPosted: Tue May 25, 2004 4:28 am 
Newbie

Joined: Thu Apr 22, 2004 4:19 am
Posts: 6
Hi,
maybe I'm asking a stupid question, but I don't understand this association:

<many-to-one name="successfulBid" column="SUCCESSFUL_BID_ID""/>

What I don't understand is why is a many-to-one association, and not one-to-one. Does it mean that a successfulBid is associated to more than one AutionItem? Why? I think a successfulBid (the winner) is only refered to a concrete item.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 25, 2004 5:00 am 
Newbie

Joined: Mon May 24, 2004 8:35 am
Posts: 2
I think this is a more conveniant way to identify the actual bid. With a one-to-one association there would be an Id shared beetween both entity. This not mean that a successfulBid is associated to more than one AutionItem?


Top
 Profile  
 
 Post subject: Question about the example provided (AutionItem)
PostPosted: Tue Jan 11, 2005 5:34 pm 
Newbie

Joined: Tue Jan 11, 2005 5:01 pm
Posts: 10
I don't think the original question is a stupid question. The example is confusing.

AuctionItem.hbm.xml includes the following entry:

<many-to-one name="successfulBid" outer-join="false"/>

The AuctionItem class has:

private Bid successfulBid;

I can find no other references in the example code to "successfulBid", but I would concur that it appears to want to express which of many bids might be the winning bid for an auction item, and as such, one auction item would have 0 or 1 successful/winning bids, and one bid could only be assigned to zero or one auction items as a successful/winning bid.

Yet, what Hibernate creates for you appears to be what you want here, and indeed, we are looking for successfulBid to be a foreign key reference to the bid table. Since a reciprocating one-to-many on the bid side has not been defined we seem to effectively have what we want. You cannot determine if a bid is a winning bid without first getting the auction item the bid is for and then asking the auction item if it is a winning bid.

So it is confusing, and since it is not used in the example code, it is unclear as well for someone looking at Hibernate for the first time.

Maybe the example authors could improve that in the future.

Dan


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 11, 2005 5:58 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
This class exists in many forms in many places. Where are you looking?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 11, 2005 6:18 pm 
Newbie

Joined: Tue Jan 11, 2005 5:01 pm
Posts: 10
Let me clarify what I said there at the end, successfulBid is not used in any of the example code (which is essentially found in Main), which leads one to perhaps wonder if it was partially removed from the example, or not entirely integrated into it.

Dan


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 11, 2005 7:08 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
I need a URL.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 11, 2005 7:33 pm 
Newbie

Joined: Tue Jan 11, 2005 5:01 pm
Posts: 10
christian wrote:
I need a URL.


Hmmm... not sure what you mean.

I've looked at both the "eg" getting started example for the 2.1 version and the 3.0 version and they are both the same in this regard.

Basically, hibernate-2.1\eg\org\hibernate\auction\AuctionItem.hbm.xml contains the <many-to-one name="successfulBid" outer-join="false"/> entry, and hibernate-2.1\eg\org\hibernate\auction\AuctionItem.java has the successfulBid component.

The example is driven by the Main class at hibernate-2.1\eg\org\hibernate\auction\Main.java which has no references to successfulBid, and there are no references to it in any other hibernate-mapping files.

So technically, the example produces an auctionItem table with a successfulBid column, and an index on successfulBid for the foreign key reference to the bid table, but the example does not interact with the column/component in a way that confirms the usage of the column/component in the example for those looking to understand its purpose, which is what makes it confusing.

HTH.

Thanks,

Dan


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.