0

我有一个带有 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;
}

我正在尝试删除 aPatientVisitTransaction并收到错误消息: mappedBy reference an unknown target entity property: TransactionNoteDW.transaction_id in PatientVisitTransaction.notes.
我猜它正在尝试映射notestransaction_id. 我如何指定正确的映射,或者我是否完全偏离了我的评估?

4

1 回答 1

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;
}
于 2013-07-24T20:34:46.577 回答