>>>>> Test Fork <<<<<
In order to make my Collections observable for JavaFX I used the JavaFX bean convention to wrap them in javafx.beans.Properties.
Hibernate is not able to refresh Entities with Collections (ElementCollection, ManyToMany, OneToMany) correctly.
In this Example the contacts are wrapped inside a ListProperty, so the ui gets notified on changes. I provide JPA with property acces on the getContacts() method.
All operations seem to work fine with the property access. It is possible to
persist() a Person (contacts in the DB Table are being inserted)
find() a Person (the contacts are fetched correctly from the DB and are available in contactsProperty() and getContacts())
flush() a change to a Person (contacts are being updated in the DB Table correctly)
But it is not possible to refresh() a Person. The contacts do not get updated.
Platform: Windows 10
Please provide a test case. You can find test templates at: https://github.com/hibernate/hibernate-test-case-templates
I provided a test case. It is the first line of the description.
There seems to be a seperate test case field, but it is the only field I cannot edit.
Oh, I see now. Thanks.
The problem is that the getter Person#getContacts returns a SimpleListProperty, and Hibernate expects a PersistentCollection to be returned. Since the SimpleListProperty is not found in the PersistenceContext, it's not evicted, As a result, the collection is not refreshed.
I believe that you'll need to create a custom collection type to get this working.