Hello,
I am new to JPA, but I have reviewed the documentation and still cannot figure out how to resolve the following error. I would really appreciate your help to figure out this error.
Thanks in advance for your time and comments,
Mike
-------------------------------------------
Multiple writable mappings exist for the field [Licenses.CustomerId]. Only one may be defined as writable, all others must be specified read-only. Mapping: org.eclipse.persistence.mappings.ManyToOneMapping[customerVendorProduct] Descriptor: RelationalDescriptor(entities.License --> [DatabaseTable(Licenses)]) Runtime Exceptions:
-------------------------------------------
Here are the relationships that are involved:
* is the primary key.
Customer (1) ---- (n) License (n) ---- (1) CustomerVendorProduct
*CustomerId *LicenseId *CustomerId+*VendorId+*ProductId
CustomerId (fk)
Here is the relavant code for each entity:
----- CUSTOMER ENTITY ------------------------------
@Id
@Basic(optional = false)
@NotNull
@Column(name = "CustomerId")
private Long customerId;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "customer")
private Collection<CustomerVendorProduct> customerVendorProductCollection;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "customer")
private Collection<License> licenseCollection;
---------------------------------------------------
----- CUSTOMERVENDORPRODUCT ENTITY ----------------
@EmbeddedId
protected CustomerVendorProductPK customerVendorProductPK;
@JoinColumn(name = "VendorId", referencedColumnName = "VendorId",
insertable = false, updatable = false)
@ManyToOne(optional = false)
private Vendor vendor;
@JoinColumn(name = "ProductId", referencedColumnName = "ProductId",
insertable = false, updatable = false)
@ManyToOne(optional = false)
private Product product;
@JoinColumn(name = "CustomerId", referencedColumnName = "CustomerId",
insertable = false, updatable = false)
@ManyToOne(optional = false)
private Customer customer;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "customerVendorProduct")
private Collection<License> licenseCollection;
---------------------------------------------------
---- LICENSE ENTITY -------------------------------
@Id
@Basic(optional = false)
@NotNull
@Column(name = "LicenseId")
private Long licenseId;
@JoinColumns({
@JoinColumn(name = "CustomerId", referencedColumnName = "CustomerId"),
@JoinColumn(name = "VendorId", referencedColumnName = "VendorId"),
@JoinColumn(name = "ProductId", referencedColumnName = "ProductId")})
@ManyToOne(optional = false)
private CustomerVendorProduct customerVendorProduct;
@JoinColumn(name = "CustomerId", referencedColumnName = "CustomerId")
@ManyToOne(optional = false)
private Customer customer;
----------------------------------------------------