I am currently developing and application using JAVAFX, JPA, EclipseLink...
So far so good, I could use a POJO that JPA and JAVAFX likes and works, until I needed to add a Set, the Set in the JavaFX world is a SetProperty, So I added it:
I have a pojo defined like this: (I simplified all code)
the other department class is like:
I am getting this error now:
Exception [EclipseLink-127] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The get method for the attribute [depts] does not return a ValueHolderInterface, but the mapping uses indirection.
Descriptor: RelationalDescriptor(package.Company --> [DatabaseTable(Company)])
What am I doing wrong?
Maybe JPA is not understanding ObservableSet? what should I use as a Set in JavaFX that is also compatible with JPA?
Such a solution has some drawbacks as probably it won't be very dry and may require additional logic for data co-ordination.
But, on the other hand an MVVM solution would likely may avoid some issues that you may run across when some view properties are in entity model classes (such as the ObservableSet one). MVVM would also allow you to have a model which closely follows your domain and view-model classes which closely follow your UI.
If you wish to include JavaFX properties in JPA classes, then this example by james-d might be interesting. It also won't address your set question. The reasoning behind the code in James's example is explained in his blog.
I understand what you are saying, the thing is, I am pretty advanced in the development so I think I wont change the architecture at this point.
Is this the only way to do it? can I use another type of Collection that works natively?
Many many thanks for all your help.
John Damien Smith
posted 3 years ago
> Is this the only way to do it? can I use another type of Collection that works natively?
Well you can always use standard java.util collections like List or Set, you don't need to use JavaFX Observable collections in your entity code. Hibernate/JPA works fine with java.util collections.
There are factory methods in FXCollections for creating ObservableLists from standard java.util collections when you need them. You won't get change notifications when the backing list changes with such a setup, but you might not need that and if you do, you can set up an alternate change notification mechanism (I don't have any code for that).