-->
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: Simple analysis question
PostPosted: Mon Jun 16, 2008 8:56 am 
Newbie

Joined: Wed May 28, 2008 6:49 am
Posts: 3
Hi all, i've a simple question that blocks me.

I have a parent-children association with "unusual" many-to-many table: this table has an attribute specified for every row.

E.g.

Parent Table
ID

Parent-Children Table
Parent_id
Child_id
Attribute

Children Table
ID

In my Parent class i would need all children List. Usually i use an ArrayList for many-to-many collection, but in this case i have a specific attribute for every single child.

How can i solve the problem? i have to create a specific object for association (containing child and attribute)? or i can use any "trick"?

thanks for any answer.

nickponico


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 16, 2008 8:58 am 
Newbie

Joined: Wed May 21, 2008 6:57 am
Posts: 8
relationship tables cannot containt additional attributes, so your parent-children table cannot be regarded as a relationship anymore but as an entity


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 16, 2008 9:07 am 
Beginner
Beginner

Joined: Tue Dec 12, 2006 6:43 am
Posts: 32
Location: London
Hi,
Just some thought which may help.

What is the purpose of the attribute in the interestion table ( parent-children). As I guess, there is not attribute defined in the interesction table. Can you justify why?


Have you taken a look at the Person Event tutorial source code. The tutorila is part of the hibernate download zipped file.

Why you want to use list instead of the set in your many-to-many association.


Thanks

_________________
Alan Mehio
London
UK


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 16, 2008 9:51 am 
Newbie

Joined: Wed May 28, 2008 6:49 am
Posts: 3
alanmehio wrote:
Hi,
Just some thought which may help.

What is the purpose of the attribute in the interestion table ( parent-children). As I guess, there is not attribute defined in the interesction table. Can you justify why?


Have you taken a look at the Person Event tutorial source code. The tutorila is part of the hibernate download zipped file.

Why you want to use list instead of the set in your many-to-many association.


Thanks


Thanks to all for replies.

I've understood that attribute on relationships are not permitted... and i think that only (but not best) way for my problem is an entity.

I give you some answer to your question.

The reason of an attribute in an many-to-many relation is that i need a particular field for any association parent-child: this field has "flag" meaning for particular logic behaviour: if an event occur i will have a value for couple parent-child, otherwise i will have other values.

I'm working on an existing db and on an existing application, so i can't "re-think" all my domain strate.

For the set you're right: a list is unnecessary and a set is more correct.

i'm going to create an entity that will wrap a children entity and attribute.

If you have any better idea... i'm listening to you

:D

Bye

nickponico


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.