Refresh doesn't work on Collections of Observable type

Description

>>>>> 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.

Environment

Hibernate: 5.2.10
Database: MySQL57
Platform: Windows 10

Activity

Show:
Gail Badner
September 18, 2017, 9:41 PM

Please provide a test case. You can find test templates at: https://github.com/hibernate/hibernate-test-case-templates

Jonas Gilg
September 20, 2017, 11:53 PM
Edited

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.

Gail Badner
September 25, 2017, 10:39 PM

Oh, I see now. Thanks.

Gail Badner
September 26, 2017, 12:10 AM

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.

Assignee

Unassigned

Reporter

Jonas Gilg

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

Affirmative

Pull Request

None

backportDecision

None

Affects versions

Priority

Major
Configure