-->
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: Once again: Many-to-many with attribute ... still painful?
PostPosted: Mon Jul 09, 2007 6:23 am 
Newbie

Joined: Sat Jan 14, 2006 8:03 pm
Posts: 18
Hello.

Over a year ago I wrote about how to map a many-to-many relationship that had an attribute in the link table. It was a painful experience. I wound up doing it all by hand. XDoclet wouldn't generate my tables correctly so I hand-hacked my mapping files. And I couldn't find a way to tell Hibernate to deal with the attribute so I had to create a class in my model that represented the link. Essentially instead of a many-to-many relation between A and B I made a new class, AB, that had a one-to-many with both A and B. I didn't like the solution because it didn't seem elegant and it most certainly wasn't easy.

Here (http://forum.hibernate.org/viewtopic.php?t=958613&highlight) is the old post.)

Now I am doing a new project and it has a bunch of tables like the one discussed in that post. Since over a year had passed I thought surely there must be a way to do this ... with Annotations. But it seems there isn't.

Without specifically asking how to do this, can anyone confirm that the ONLY way to do it is to have an intermediate composite element, including a class in the model to represent it? That way I won't waste my time searching for a more elegant and less-intrusive solution in vain.

And of course if there IS an annotation-oriented solution, I wouldn't mind knowing what it is!

FYI, an example relation is the following:

Request
id
description

Person
id
name

PersonRequest
idPerson
idRequest
date

Many thank in advance,
Bob


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.