当我在Ordonnance和Consultation类之间使用OneToOne hibernate注释时,这给了我错误:Unknown mappedBy in:com.onousc.entities.Consultation.ordonnance,引用的属性unknown:com.onousc.entities.Ordonnance.consultation。任何人都可以帮助我。非常感谢你
//班级ordonnance
package com.onousc.entities;
import java.io.Serializable; import java.util.Collection; import java.util.Date;
import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.OneToMany; import javax.persistence.OneToOne; import javax.persistence.PrimaryKeyJoinColumn;
@Entity public class Ordonnance implements Serializable{
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Integer idOrdo;
private Date dateOrdo;
@OneToMany(mappedBy="ordonnance",fetch=FetchType.LAZY)
private Collection <LigneOrdonnance> LignesOrdo;
@OneToOne(mappedBy="ordonnance")
private Lettre lettre;
@OneToOne
private Consultation consultation;
public Ordonnance() {
super();
// TODO Auto-generated constructor stub
}
public Ordonnance(Date dateOrdo) {
super();
this.dateOrdo = dateOrdo;
}
getters and setters..
}
//课堂咨询 包com.onousc.entities;
import java.io.Serializable; import java.util.Collection; import java.util.Date;
import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import javax.persistence.OneToOne; import javax.persistence.PrimaryKeyJoinColumn;
@Entity public class Consultation implements Serializable{
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Integer idConsult;
private Date dateConsult;
private String typeConsult;
private String motifConsult;
private String diagnostic;
private Boolean maladieChronique;
private String decision;
@OneToMany(mappedBy="consultation",fetch=FetchType.LAZY)
private Collection <Examen> examens;
@ManyToMany
@JoinTable(name="CONSULT_MAL")
private Collection <Maladie> maladies;
@ManyToOne
@JoinColumn(name="ID_PATIENT")
private Patient patient;
@ManyToOne
@JoinColumn(name="ID_MEDECIN")
private Medecin medecin;
@OneToOne(mappedBy="consultation")
private Ordonnance ordonnance;
public Consultation() {
super();
// TODO Auto-generated constructor stub
}
public Consultation(Date dateConsult, String typeConsult,
String motifConsult, String diagnostic, Boolean maladieChronique,
String decision) {
super();
this.dateConsult = dateConsult;
this.typeConsult = typeConsult;
this.motifConsult = motifConsult;
this.diagnostic = diagnostic;
this.maladieChronique = maladieChronique;
this.decision = decision;
}
getters and setters...