我有一个抽象的超类“RessourceMaterielle”和一个实体派生类“Vehicule”。 我在sperclass和另一个类“Localization”之间有一对一的映射。 抽象超类未在数据库中表示。我希望派生类继承超类和Localization之间的映射,以便Hibernate看到Vehicule和Localization之间的映射。这可能吗?
超类:
@MappedSuperclass
public abstract class RessourceMaterielle extends ObjetMetier {
private String nom = null;
private Localisation localisation = null;
@Column(name = "`NOM`")
public String getNom() {
return this.nom == null ? null : new String(this.nom);
}
public void setNom(String nom) {
this.nom = new String(nom);
}
@OneToOne(cascade={CascadeType.ALL})
@JoinColumn(name="`LOCALISATION`")
public Localisation getLocalisation() {
return this.localisation == null ? null : this.localisation.clone();
}
public void setLocalisation(Localisation localisation) {
this.localisation = localisation.clone();
}
public RessourceMaterielle(){
}
}
VEHICULE:
@Entity(name = "VEHICULE")
@Table(name = "`VEHICULE`")
public class Vehicule extends RessourceMaterielle {
public Vehicule() {
}
}
位置:
@Entity(name = "LOCALISATION")
@Table(name = "`LOCALISATION`")
public class Localisation extends ObjetMetier {
private double lon = -1111;
private double lat = -1111;
private RessourceMaterielle ressourceMaterielle;
@OneToOne(cascade = { CascadeType.ALL }, mappedBy = "localisation")
public RessourceMaterielle getRessourceMaterielle() {
return (RessourceMaterielle) (this.ressourceMaterielle == null ? null : this.ressourceMaterielle.clone());
}
public void setRessourceMaterielle(RessourceMaterielle ressourceMaterielle) {
this.ressourceMaterielle = ressourceMaterielle;
}
@Column(name = "`LON`")
public double getLon() {
return this.lon;
}
public void setLon(double lon) {
this.lon = lon;
}
@Column(name = "`LAT`")
public double getLat() {
return this.lat;
}
public void setLat(double lat) {
this.lat = lat;
}
public Localisation() {
}
public Localisation(double lon, double lat) {
this.setLon(lon);
this.setLat(lat);
}
}
当我运行将Vehicule持久存储到数据库中的测试时,我收到以下错误:
org.hibernate.AnnotationException: Unknown mappedBy in: com.organisme.model.localisation.Localisation.ressourceMaterielle, referenced property unknown: com.organisme.model.ressource.RessourceMaterielle.localisation
有没有解决方案?
问候。