-->
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.  [ 1 post ] 
Author Message
 Post subject: One-to-many association mapping issue(suggestion)
PostPosted: Tue Jan 16, 2007 8:11 pm 
Regular
Regular

Joined: Sun Sep 17, 2006 2:48 am
Posts: 81
Location: California
I am using hibernate 3.2.1, java 6

What would be the correct way of mapping the following scenario in hibernate?

I want to acheive the following:

User table
------------
A
B
C

Products table
----------------
P1
P2
P3

Products Rating table
--------------------------
R1 P1 A
R2 P1 A
R3 P1 A
R4 P3 A
R5 P1 C
R6 P1 C
R7 P2 C


Currently I am using 1-n between User and Rating (means each user can rate multiple times and a rating is by a specific user), and 1-n between Product and Rating(means each product will have multiple ratings but each rating is only for a single product).

Somehow this mapping is not appealing me. Not sure what is wrong though.
On going through the hibernate document I found this

6.2.5. One-to-many associations
A one to many association links the tables of two classes via a foreign key, with no intervening collection table. This mapping loses certain semantics of normal Java collections:
* An instance of the contained entity class may not belong to more than one instance of the collection
* An instance of the contained entity class may not appear at more than one value of the collection index


So my mapping is actually violating the first point. Can anybody please suggest what would be the correct way of mapping this scenario, in case I am doing it in a wrong way?

Thanks


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

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.