0

I want to create a oneToOne relation between PatientEntity and MonitoringEntity but i have this error :The attribute [patient] in entity class [class ch.lestoises.monitopsy.medication.entity.MonitoringEntity] has a mappedBy value of [monitoringCode] which does not exist in its owning entity class [class ch.lestoises.monitopsy.patient.entity.PatientEntity]. If the owning entity class is a @MappedSuperclass, this is invalid, and your attribute should reference the correct subclass. and this is my code :

@Entity
@Table(name = "patient")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PatientEntity.findByNumber", query = "SELECT p FROM PatientEntity p WHERE p.patientNumber = :number"),
    @NamedQuery(name = "PatientEntity.findAllPatient", query = "SELECT p FROM PatientEntity p ")
})
public class PatientEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "pk_patient")
    private Integer pkPatient;

    @NotNull
    @Column(name = "name")
    private String name;

    @NotNull
    @Column(name = "firstname")
    private String firstname;

    @OneToOne
    @JoinColumn(name="pk_monitoring")
    private transient MonitoringEntity monitoringCode;
} the Monitoring class : @Entity
public class MonitoringEntity {

    @Id
    @Column(name = "pk_monitoring")
    private Integer pkMonitoring;

    @OneToOne(mappedBy="monitoringCode")
    private PatientEntity patient;
}
kao
  • 11
  • 5

1 Answers1

0

I should remove the transient and @JoinColumn for field monitoringCode in PatientEntity

kao
  • 11
  • 5