我尝试使用 Maven 框架为我的程序创建一个数据库。但是,我遇到了这种错误。
Invocation of init method failed; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: tugas1.sidok.model.Jadwal_JagaModel.jadwal_jaga in tugas1.sidok.model.DokterModel.jadwal
这是我对 DokterModel 和 Jadwal_JagaModel 的以下程序
DocterModel.Java
@Entity
@Table(name = "dokter")
public class DokterModel implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "dokter_id")
private long idDokter;
@Size(max = 255)
@Column(name = "NIP", nullable = false)
private String nip;
@Size(max= 255)
@Column(name="NIK", nullable = false)
private String nik;
@Size(max = 255)
@Column(name = "nama", nullable = false)
private String nama;
@Column(name = "tanggal_lahir", nullable = false)
private Date tanggalLahir;
@Column (name = "jenis_kelamin", nullable = false)
private Boolean jenisKelamin;
@Size(max = 255)
@Column (name = "tempat_lahir")
private String tempatLahir;
@ManyToMany(mappedBy = "jadwal_jaga")
private List<Jadwal_JagaModel> jadwal;
//Setter getter //
Jadwal_JagaModel.Java
@Entity
@Table(name = "jadwal_jaga")
public class Jadwal_JagaModel {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "jadwal_jaga_id")
private long id;
@Size(max = 255)
@Column(name = "hari", nullable = false)
private String hari;
@ManyToMany(cascade = {CascadeType.ALL})
@JoinTable(
name = "Dokter_Jadwal_Jaga",
inverseJoinColumns = {@JoinColumn(name = "dokter_id", referencedColumnName = "dokter_id")},
joinColumns = {@JoinColumn(name = "jadwal_jaga_id",referencedColumnName = "jadwal_jaga_id")}
)
private List<DokterModel> jadwalDokters;
// Setter getter //
我知道问题是在DokterModel.Java中的 mappedBy ,但是,我不确定它应该是什么以及 mappedBy 如何工作?这是我第一次使用 Hibernate,因此感谢任何形式的帮助。