Using JFace binding with Hibernate: is this possible?

Our project is an RCP Eclipse application using Hibernate as an ORM. I recently learned about JFace data binding, in which the GUI and data models can be synchronized automatically.

I put together a short test implementation on the Lars Vogel line, the excellent JFace Data Binding Tutorial, and was impressed with the frame.

Is it possible to associate this with Hibernate so that changes to the observed widget are automatically saved to the database? This seems like a natural thing to do, and yet I have not found any good textbooks.

I suspect that I may bark the wrong tree or skip the fundamental concept.

Has anyone tried to do this? What is the "best practice" here?

+4
source share
1 answer

I do not think that you should save your data model in the database after each modification in the graphical interface. Some reasons:

  • this can lead to really bad performance (the worst case is updating the database after every keystroke)
  • it can be difficult to implement some actions with the graphical interface (for example, can your user "cancel" the editing operation? How do you "restore" the original values?)

If your application contains any kind of Apply / Save / etc. and the β€œCancel” button, you have some well-defined points where you need to perform database operations:

  • use data binding to connect your data model and GUI
  • The button handler Apply or Save saves the edited object in the database
  • The handler of the "Cancel" button may, if necessary, reload the edited object from the database (discarding the changes)

Only my two cents ...

Disclaimer I used the very simple examples above to illustrate my thoughts. For instance. you should never invoke database / Hibernate operations directly from the GUI (use the "middle tier" between the GUI and the database to ensure modularity and testability).

+2
source

All Articles