I'm developing a Java desktop application and was really interested in use JavaFX. I'm planning to use an MVC architecture because I have had some experience with Java EE and the MVC model.
I want to store data in a embedded derby database and use Hibernate as persistence layer but I can't find a great tutorial about implementing MVC with hibernate and JavaFX.
I have created the persistence file but I am not sure how to make it work with JavaFX. In Java EE I inject EJB services or DAOs but since my app is not server connected I think I can't do that.
Can someone explain me how to achieve that? It is possible to use them together?
In one of my last JavaFX Projects, I created under my Service Layer a DataBroker class, which could do all the CRUD Operations on the Database.
Example:
If you only need one DataBroker Instance, you maybe can realize it as a Singleton, if you need a Pool of Instances, create a Pool. This is the advantage of a Application Server, he does this all for you and you only have to annotate your Classes or Members.
I hope this will help you.
EDIT / UPDATE Here is a working example with EclipseLink 2.1, but it is only the Persistence Provider, so it works also with Hibernate.
I created a DataBroker like in the above example which implements my IDataBroker Interface and overrides the methods.
IDataBroker
DataBroker - not every method is implemented...
IPersonService Interface
PersonService
Our Domain class Person
The FXMLController class
And last but not least the MainApp to start the Application.
This is a standard Maven JavaFX Project created with Netbeans 8. If necessary I can upload the Sources to GitHub or something..
The Database Table will be created with the first commit, because i set up in the persistence.xml file, that Schema Generation as you can see from the file
So I hope this will help you to create your project.
Patrick