@Entity
public class Purveyor implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int ref_purveyor;
@Column(unique = true)
private String purveyor_name;
@Column(unique = true)
private int purveyor_number;
@Column(unique = true)
private String adress;
@Column(unique = true)
private int fax;
/**
*
* @return This returns the purveyor's ID.
*/
public int getRef_purveyor() {
return ref_purveyor;
}
/**
*
* @param ref_purveyor
* This refers to the ID of the new purveyor.
*/
public void setRef_purveyor(int ref_purveyor) {
this.ref_purveyor = ref_purveyor;
}
/**
*
* @return This return the name of the purveyor.
*/
public String getPurveyor_name() {
return purveyor_name;
}
/**
*
* @param purveyor_name
* This refers to the new purveyor's name.
*/
public void setPurveyor_name(String purveyor_name) {
this.purveyor_name = purveyor_name;
}
/**
*
* @return This returns the purveyor's number.
*/
public int getPurveyor_number() {
return purveyor_number;
}
/**
*
* @param purveyor_number
* This refers to the new purveyor's number.
*/
public void setPurveyor_number(int purveyor_number) {
this.purveyor_number = purveyor_number;
}
/**
*
* @return This returns purveyor's adress.
*/
public String getAdress() {
return adress;
}
/**
*
* @param adress
* This refers to the new purveyor's adress.
*/
public void setAdress(String adress) {
this.adress = adress;
}
/**
*
* @return This returns the purveyor's fax.
*/
public int getFax() {
return fax;
}
/**
*
* @param fax
* This refers to new purveyor's fax.
*/
public void setFax(int fax) {
this.fax = fax;
}
/*@OneToMany(mappedBy = "orders")
private Collection<Order> orders = new ArrayList<Order>();*/
@OneToMany(fetch=FetchType.LAZY,mappedBy = "deliveries")
private List<Delivery> deliveries = new ArrayList<Delivery>();
/**
*
* @see Order This refers to purveyor's Orders.
*/
/*public Collection<Order> getOrders() {
return orders;
}*/
/**
*
* @param orders
* This refers to the orders of the purveyor.
*/
/*public void setOrders(Collection<Order> orders) {
this.orders = orders;
}*/
/**
*
* @see Delivery This refers to purveyor's deliveries
*/
public List<Delivery> getDeliveries() {
return deliveries;
}
/**
*
* @param deliveries
* This refers to the deliveries of the purveyor.
*/
public void setDeliveries(List<Delivery> deliveries) {
this.deliveries = deliveries;
}
public static long getSerialversionuid() {
return serialVersionUID;
}
}
======================-------------------------------==============================
@Entity
` public class Delivery implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name = "delivery_ref")
@GeneratedValue
private int delivery_ref;
@Column(unique = true)
private Date delivery_date;
@Column
private int quantity;
/**
* @return This returns the reference of the delivery.
*/
public int getDelivery_ref() {
return delivery_ref;
}
/**
*
* @param delivery_ref
* This refers to the new delivery.
*/
public void setDelivery_ref(int delivery_ref) {
this.delivery_ref = delivery_ref;
}
/**
* @return This returns the delivery date.
*/
public Date getDelivery_date() {
return delivery_date;
}
/**
*
* @param delivery_date
* This refers to the new date of delivery.
*/
public void setDelivery_date(Date delivery_date) {
this.delivery_date = delivery_date;
}
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name = "ref_purveyor")
private Purveyor purveyor;
@OneToOne(mappedBy = "delivery", cascade = CascadeType.ALL)
private BillDelivery billD;
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public BillDelivery getBillD() {
return billD;
}
public void setBillD(BillDelivery billD) {
this.billD = billD;
}
public Purveyor getPurveyor() {
return purveyor;
}
public void setPurveyor(Purveyor purveyor) {
this.purveyor = purveyor;
}
}
Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: x.Delivery.deliveries in x.Purveyor.deliveries
I tried the solutions already mentionned in this site but it doesn't work for me.
Can anybody helps me to resolve this issue
The message is pretty clear. You're saying to JPA: this OneToMany is the inverse side of the ManyToOne, defined in the Delivery
entity, by the field deliveries
. But there is no field deliveries
in Delivery
. The corresponding field in Delivery is named purveyor
:
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name = "ref_purveyor")
private Purveyor purveyor;
^-- this is the other side of the association
So what you need is
@OneToMany(fetch=FetchType.LAZY,mappedBy = "puveyor")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With