我有一个带有Hibernate注释的Java类,它引用了另一个POJO:
@Entity
@Table(name = "Patient_Visit_Transaction")
public class PatientVisitTransaction extends Bean {
@OneToMany(fetch = FetchType.LAZY)
@JoinColumn(name = "transaction_id")
List<TransactionNoteDW> notes;
....
}
另一类是这样的:
@Entity
@Table(name = "Transaction_note_dw")
public class TransactionNoteDW extends DateAuditableBean {
@Id
@Column(name = "note_seq")
private long id;
@Column(name = "transaction_id")
private String transactionId;
}
我正在尝试删除PatientVisitTransaction
并收到错误消息:
mappedBy reference an unknown target entity property: TransactionNoteDW.transaction_id in PatientVisitTransaction.notes
。
我想它正试图将notes
映射到transaction_id
。如何指定正确的映射,还是完全取消评估?
答案 0 :(得分:1)
我想你可能想这样映射:
public class TransactionNoteDW extends DateAuditableBean {
//....
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "patient_id")
private PatientVisitTransaction patient;
}
public class PatientVisitTransaction extends Bean {
//....
@OneToMany(fetch = FetchType.LAZY, mappedBy = "patient")
List<TransactionNoteDW> notes;
}