I facing issue related to @OneToMany with @JoinColumn .I am not able to find the solution.It gives me Exception when i am mapping that orderNo column How I Can mapping my OrderNo Column of LabOrder table to LabOrderTests table Order Column.Anyone can help me how can resolve this issue .
@Entity
@Table(name = "laborder")
public class LabOrder implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "labOrder",orphanRemoval = true)
@JoinColumn(name = "orderNo", referencedColumnName = "orderNo")
private List<LabOrderTests> labOrderTests;
}
@Entity
@Table(name = "labordertests")
public class LabOrderTests implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long ID;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "orderNo")
private LabOrder labOrder;
}
Exception Log:
Caused by: org.hibernate.AotationException: Associations marked as mappedBy must not define database mappings like @JoinTable or @JoinColumn: com.product.domain.LabOrder.labOrderTests
at org.hibernate.cfg.aotations.CollectionBinder.bind(CollectionBinder.java:526)
at org.hibernate.cfg.AotationBinder.processElementAotations(AotationBinder.java:1956)
at org.hibernate.cfg.AotationBinder.processIdPropertiesIfNotAlready(AotationBinder.java:767)
at org.hibernate.cfg.AotationBinder.bindClass(AotationBinder.java:686)
