将 JFace 数据绑定与 Hibernate 结合使用:这可能吗?
我们的项目是一个使用 Hibernate 作为 ORM 的 Eclipse RCP 应用程序。我最近了解了 JFace 数据绑定,其中 GUI 和数据模型可以自动同步。
我按照 Lars Vogel 优秀的 JFace 数据绑定教程 并且对该框架印象深刻。
那么,有什么方法可以将其挂接到 Hibernate 中,以便在观察到的小部件中所做的更改自动保留在数据库中吗?这似乎是很自然的事情,但我没有找到好的教程。
我怀疑我可能找错了方向,或者错过了一些基本概念。
有人尝试这样做吗?这里的“最佳实践”是什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您不应该在每次修改 GUI 后将数据模型保存到数据库中。一些原因:
如果您的申请表包含某种“应用”/“保存”等内容。按钮和取消按钮 您有一些明确定义的点,您需要在其中执行数据库操作:
只是我的两分钱...
免责声明:我在上面使用了非常简单的示例来说明我的想法。例如,您永远不应该直接从 GUI 调用数据库/Hibernate 操作(在 GUI 和数据库之间使用“中间层”以确保模块化和可测试性)。
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).