Mantis - Resin
Viewing Issue Advanced Details
1576 major always 01-21-07 11:19 04-12-07 20:27
closed 3.1.1  
none 3.1.1  
0001576: @OneTOMany and Inheritance problem
I'm going through your Amber tutorial. Works like a charm. I decide to play a bit with it so I expanded the “course” table with a discriminator column and another column called “formula”.

I introduce a new class called RaceCourse, which extends from the Course class. With the following annotations:

@Table(name = "amber_basic_course")
@DiscriminatorColumn(name="discriminator", discriminatorType=DiscriminatorType.STRING)
@DiscriminatorValue(value = "course")


It works perfectly. So I create a class and table called participant. And a ManyToOne relation from the participant to the table:

@ManyToOne@JoinColumn(name="course_id", nullable=false)
public Course getCourse() {
    return course;

Course_id is a foreign key to the course table. This also works perfectly.

Finally I introduce the @OneToMany in the Course class:

@OneToMany(cascade=CascadeType.ALL, mappedBy="course")
public Set<Participant> getParticipants() {
return participants;

I can get the participants from the courses. No problem. The problem is the RaceCourse is no longer loaded properly (I use annotation on the properties not the fields). The setter methods for teacher, and formula are no longer called. Removing the getParticipants and setParticipants methods from the course class makes it all work perfectly again.

To me it seems like there is a problem with one to many and inheritance. I can reproduce this every time. I have attached the code if you would like to look at it.

04-12-07 20:27