-->
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.  [ 4 posts ] 
Author Message
 Post subject: Relationship with attribute
PostPosted: Sun Jan 14, 2007 8:05 am 
Newbie

Joined: Sun Jan 14, 2007 8:01 am
Posts: 2
(Hibernate 3.1.3)

I have a relationship between 2 entities (Product and Seller) with an attribute (prices).

Is there a way to realize this link without creating a new entity (Price_for_Product_to_Seller)?

Thank you


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 14, 2007 3:54 pm 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
I guess you speak about a many-to-many relationship.

If the relationships holds an attribute, I think it's impossible. Think about it: what would be the object each side is holding and how could each side access the prices attribute if the object contained in the collection does not hold this attribute?

If the relationship between the two entities is simply represented by a relation table, then no need to have a intermediary object, but if it has an attribute, then I guess a relation class is needed imo.

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject: I don't think so
PostPosted: Sun Jan 14, 2007 6:25 pm 
Beginner
Beginner

Joined: Sat Dec 16, 2006 1:52 pm
Posts: 40
I don't think there is. I have searched for such a thing since I do have a special situation where I need to use an objects ID only and can NOT use the full object. But in this case I found that I can just wrap the object in something that hides all of its methods except for its ID. And then its safe to use as if it were just an ID sort of.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 22, 2007 2:41 pm 
Beginner
Beginner

Joined: Sat Dec 16, 2006 1:52 pm
Posts: 40
I have found a way to do this. I have 2 mapping files. 1 mapping is used for schema creation, the other is used for runtime usage. The creation mapping uses a class to define the relationship. But the runtime mapping instead maps this column to a property which is simply a Long.


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