Quote:
When you call setContacts, you never set the contacts property so Hibernate can never propagate the changes to the DB.
Where do I not set the contactsProperties?
Code:
contactsProperty.set(FXCollections.observableList(contacts));
And why does Hibernate update the DB Table/Object correctly, when I call:
Code:
//works
entityManager.getTransaction().begin();
entityManager.persist(person);
entityManager.getTransaction().commit();
############################################
//works
person.getContacts().add("SomeContact");
entityManager.getTransaction().begin();
entityManager.flush();
entityManager.getTransaction().commit();
############################################
//works
person.contactsProperty().add("SomeContact");
entityManager.getTransaction().begin();
entityManager.flush();
entityManager.getTransaction().commit();
############################################
//works
entityManager.getTransaction().begin();
Person person = entityManager.find(Person.class, id);
entityManager.getTransaction().commit();
It only fails to update the object correctly when I call
Code:
//fails (contents of contacts is the same even if the db table changed)
entityManager.refresh(person);
Quote:
Also, what's the reason you are mixing field-based access with property-based access? Either you use one or the other.
I don't understand, what you mean here. I follow the JavaFX Beans convention which looks like this (
http://docs.oracle.com/javafx/2/binding/jfxpub-binding.htm):
Code:
private Property<T> fieldProperty;
public Property<T> fieldProperty() { return fieldProperty; }
public T getField() { return fieldProperty.get(); }
public void setField(T field) { fieldProperty.set(field); }
Isn't the ability to annotate the getter specifically for the case, where the field is not persistable? (when getter/setter does custom stuff)