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