Reputation: 25032
I have a Java class with Hibernate annotations that refers to another POJO:
@Entity
@Table(name = "Patient_Visit_Transaction")
public class PatientVisitTransaction extends Bean {
@OneToMany(fetch = FetchType.LAZY)
@JoinColumn(name = "transaction_id")
List<TransactionNoteDW> notes;
....
}
The other class is this:
@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;
}
I am trying to delete a PatientVisitTransaction
and I get an error:
mappedBy reference an unknown target entity property: TransactionNoteDW.transaction_id in PatientVisitTransaction.notes
.
I guess it is trying to map the notes
to transaction_id
. How do I specify the correct mapping or am I completely off on my assessment?
Upvotes: 0
Views: 71
Reputation: 2204
I think you might want to map like this:
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;
}
Upvotes: 1