Hi,
I have the following probleme:
I have an entity "Contact" which have two @OneToOne relations to an entity "Address". If I perform an update on the contact entity only the "simple properties" of type "String, Integer, Boolean, and so on) will be updated. The properties with an relation (@OneToOne for example) are not updated on transaction.commit() and manager.close(). The Update is only visible if I restart my application. Here the related code:
Code:
@javax.persistence.Entity
public class Contact {
// ...
private String firstName;
@OneToOne(cascade = CascadeType.ALL, optional = true, fetch = FetchType.LAZY)
private Address privateAddress;
@OneToOne(cascade = CascadeType.ALL, optional = true, fetch = FetchType.LAZY)
private Address commercialAddress;
// ...
The update looks like this:
Code:
final Contact contact = ...
final EntityManager manager = factory.createEntityManager();
contact.setFirstName("NEW FIRST NAME"); // updated after commit
contact.getPrivateAddress().setStreet("NEW_STREET"); // not updated after commit
manager.getTransaction().begin();
manager.getTransaction().commit();
manager.close();
Does someone knows an solution?
Thanks :)
Best regards
QStorm