@ManyToMany in an abstract MappedSuperclass

I'm having the following design for my hibernate project:

@MappedSuperclass
public abstract class User {
    private List<Profil>    profile;

    @ManyToMany (targetEntity=Profil.class)
    public List<Profil> getProfile(){
        return profile;
    }
    public void setProfile(List<Profil> profile) {
        this.profile = profile;
    }
}

@Entity
@Table(name="client")
public class Client extends User {
    private Date    birthdate;
    @Column(name="birthdate")
    @Temporal(TemporalType.TIMESTAMP)
    public Date getBirthdate() {
        return birthdate;
    }
    public void setBirthdate(Date birthdate) {
        this.birthdate= birthdate;
    }
}

@Entity
@Table(name="employee")
public class Employee extends User {
    private Date    startdate;
    @Column(name="startdate")
    @Temporal(TemporalType.TIMESTAMP)
    public Date getStartdate() {
        return startdate;
    }
    public void setStartdate(Date startdate) {
        this.startdate= startdate;
    }
}

As you can see, User hat a ManyToMany relationship to Profile.

@Entity
@Table(name="profil")
public class Profil extends GObject {
    private List<User>  user;

    @ManyToMany(mappedBy = "profile", targetEntity = User.class )
    public List<User> getUser(){
        return user;
    }
    public void setUser(List<User> user){
        this.user = user;
    }
}

If I now try to create an employee, i get a hibernate exception:

org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: de.ke.objects.bo.profile.Profil.user [de.ke.objects.bo.user.User]

Как я могу использовать отношение ManyToMany к профилю в суперклассе User , поэтому он работает для Клиента и Сотрудника ?

5
задан slartidan 24 September 2018 в 12:20
поделиться