java swing应用程序中数据库和用户界面之间自动数据绑定的最佳方法? [英] Best way for automatic databinding between database and user interface in java swing app?

查看:30
本文介绍了java swing应用程序中数据库和用户界面之间自动数据绑定的最佳方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前需要为具有数十个表和数千个字段的数据库创建用户前端应用程序.

I'm currently facing a need of creating user frontend application to database with dozens of tables and thousands of fields.

它应该是 java swing 应用程序,我试图找到尽可能自动化的解决方案.理想情况下完全避免手动创建 DAO 层、bean 定义和 GUI 创建.

It should be java swing application, and I'm trying to find as most automated solution as possible. Ideally to completely avoid manual creation of DAO layer, beans definition and GUI creation.

目前我们正在讨论将数据库转换为一组 XML 文档的可能性,因此解决方案应该包括处理关系数据库和 XML 文档的能力.

Currently we are discussing the possibility of transforming database to set of XML documents, so the solution should include the capability of working with both, relational database as well as XML documents.

有什么想法/经验吗?

推荐答案

实际上有两个步骤:

第一个是选择一个对象关系映射器(ORM).这可以是 JPA 提供者、JDO 提供者或类似 Hibernate 的东西.JPA 是 Java 对象和数据库之间映射的语言支持规范.我也使用过 Hibernate(Hibernate 令人困惑,因为它既是一个独立的 ORM 又是一个 JPA 提供者)并且它对我来说效果很好.您的 ORM 将描述您将 Java 对象的类/字段存储到哪些表/行中,它还将提供事务和机制,以便在您的应用程序方便时保留 Java 对象更改.

1st is to choose an object relational mapper (ORM). This can be a JPA provider, JDO provider, or something like Hibernate. JPA is the language supported specification for mapping between your Java objects and your database. I have also used Hibernate (Hibernate is confusing because it is both a stand alone ORM and a JPA provider) and it has worked well for me. Your ORM will describe what tables/rows you store your Java object's classes/fields into and it will also provide transactions and a mechanism to persist your Java object changes when it is convenient for your application.

如果您正在考虑存储到 XML,那么您可能需要查看 DataNucleus 作为早期支持 xml 存储的 JPA/JDO 提供程序.

If you are thinking about storing to XML then you may want to look at DataNucleus as a JPA/JDO provider which has early support for xml storage.

第二是选择你的绑定框架.如果您使用的是 Swing,那么 NetBeans 平台是很自然的选择,正如垃圾神所建议的那样.NetBeans 拥有大量旨在简化应用程序开发的技术,包括绑定技术.如果您使用 NetBeans IDE,那么您将获得一个内置的 GUI 创建工具.我没有使用 GUI 创建工具的经验,所以我不能说更多.

2nd is to choose your binding framework. If you are using Swing then the NetBeans platform is a natural choice as trashgod suggested. NetBeans has a whole slew of technologies meant to ease your application development including binding technologies. If you use the NetBeans IDE then you get a GUI creation tool built in. I have no experience with the GUI creation tool so I can't say much more than it exists.

如果您正在直接将 Swing 富客户端连接到数据库,那么您不需要使用 DAO.DAO 在客户端和服务器上都有代码的多层应用程序中很有用.如果您在客户端上运行所有逻辑,而服务器只是一个数据库,那么您不需要 DAO.

If you are doing a straight Swing rich client to database then you do not need to use DAOs. DAOs are useful in multi-tier apps where there is code on both the client and the server. If you are running all your logic on the client and the server is just a database then you do not need DAOs.

这篇关于java swing应用程序中数据库和用户界面之间自动数据绑定的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆