-->
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.  [ 2 posts ] 
Author Message
 Post subject: Get attribute from join table
PostPosted: Wed Feb 14, 2007 4:56 pm 
Newbie

Joined: Fri Feb 02, 2007 12:10 am
Posts: 4
Hi,

I've googled a lot, searched this forum and the documentation but I could not solve my problem. So here it is:

I have two tables which are joined through a third one:

person -------> person_program ------------> program

The relationship between person and program is ManyToMany so the person object in my application has a list of programs which works fine so far. But the problem is that the person_program table holds some information about the relation. It has two attributes start and stop date. So it looks like:

person_program(person, program, start_date, stop_date)

I tried to get the two date attributes by adding a second table to the program entity:

Code:
@SecondaryTable(@SecondaryTable( name="person_subscription",
                uniqueConstraints={@UniqueConstraint(columnNames={"person", "program", "start_date", "stop_date"})},   
pkJoinColumns=@PrimaryKeyJoinColumn(name="program", referencedColumnName="id" ) )


With that I get the two date attributes but not distinct. It looks as if the program table joins the person_program table a second time so all entries are duplicated in the list of the person. Does anyone know how to solve that problem?


Jens

-------------------------------------------------------------------------------------------------
Hibernate version: 3.2.1

Postgresql, 8.1

I am using annotations to map the entities to the database


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 15, 2007 2:35 pm 
Newbie

Joined: Fri Feb 02, 2007 12:10 am
Posts: 4
I found this page dealing with this topic:
http://www.thearcmind.com/confluence/display/RandomThoughts/Hibernate+need+to+access+properties+on+join+table

But I think that there must be an easier way!


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