Our project is an Eclipse RCP application using Hibernate as an ORM. I recently learned about JFace databinding, in which the GUI and data models can be synchronized automagically.
I put together a short test implementation along the lines of Lars Vogel’s excellent JFace Data Binding Tutorial and was fairly impressed with the framework.
Is there any way, then, to hook this into Hibernate, such that changes made in an observed widget are automatically persisted in the database? This seems like a natural thing to want to do, and yet I’ve found no good tutorials.
I suspect that I may be barking up the wrong tree, or have missed some fundamental concept.
Has anyone tried to do this? What’s the “best practice” here?
I do not think you should persist your data model to a database after every modification in the GUI. Some reasons:
If your application form contains some kind of an Apply/Save/etc. button and a Cancel button you have some well defined points where you need to do database operations:
Just my two cents…
Disclaimer: I used very simple examples above to illustrate my thoughts. E.g. you should never call database/Hibernate operations directly from the GUI (use a ‘middle tier’ between the GUI and the database to ensure modularity and testability).