Hi All,
I am re-posting this threat after having received no response from an earlier threat.
I need advice on which JPA CascadeType to use in order to enforce the unique constraint entries that exist in a Customer and Telephone OneToMany JoinTable relationship.
Let's examine the code snippets of Customer.java entity object is as follows:
The EntityManager.persist() method does a good job of inserting both Customer and Telephone records by abiding to the unique constraint of one telephone per customer when inserting new database records. EntityManager.persist() cannot be used for updating entity records as it continually try to insert existing records which throw exceptions. On the other hand, EntityManager.merge() updates or synchronise existing detached Customer entities correctly while Telephone records were duplicated (no longer unique) on the ManyToOne unidirectional side, with Customer being the owning side. Any idea on which combination of EntityManager and CascadeType would only update both Customer and Telephone entities while preserving the unique constraint OneToMany Unidirectinal relationship?
This
Java EE 5 application has been working for a few years.
I am running JDK1.6.0_7, GF2.1 (
EJB 3.0) and MySQL on Windows XP.
Your advice would be much appreciated.
Many thanks,
Jack