Hi.
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="kunde")
public class Kunde 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]
How can I use a ManyToMany-Relationship to Profile on the superclass User, so it works for Kunde and Employee?
Thanks in advance.