简体   繁体   English

自动生成EJB3实体Bean

[英]Auto-Generating EJB3 Entity Beans

I would like to know if there are any tools to automatically generate EJB3 Entity Beans(for JPA) from a database schema. 我想知道是否有任何工具可以从数据库模式自动生成EJB3 Entity Beans(用于JPA)。

Thanks. 谢谢。

Dali支持自上而下,自下而上(这是您正在寻找的),以及中间相遇的开发方法。

一些ID具有此类功能,例如NetBeans

OpenJPA has a tool which will generate your Entity definitions. OpenJPA有一个工具可以生成您的实体定义。

From the OpenJPA user manual : 从OpenJPA 用户手册

OpenJPA includes a reverse mapping tool for generating persistent class definitions, complete with metadata, from an existing database schema. OpenJPA包括一个反向映射工具,用于从现有数据库模式生成包含元数据的持久类定义。 You do not have to use the reverse mapping tool to access an existing schema; 您不必使用反向映射工具来访问现有模式; you are free to write your classes and mappings yourself, as described in Section 3, “ Meet-in-the-Middle Mapping ”. 您可以自由编写类和映射,如第3节“在中间映射中映射”中所述。 The reverse mapping tool, however, can give you an excellent starting point from which to grow your persistent classes. 但是,反向映射工具可以为您提供一个很好的起点来增加持久化类。

No IDE required! 不需要IDE!

-Rick -Rick

I have a solution for you ie to create auto generate domain objects with all table relationship properly mapped in class ...Try Dal4j yes you can find it in sourceforge.net/p/dal4j/wiki/ DAL4j is a Command Line and Framework tool that can be used to reverse engineer a MySQL or SQLServer database schema into a set of JPA Entity Beans. 我有一个解决方案,即创建自动生成域对象,所有表关系在类中正确映射...尝试Dal4j是的,你可以在sourceforge.net/p/dal4j/wiki/找到它DAL4j是一个命令行和框架工具可用于将MySQL或SQLServer数据库模式反向工程为一组JPA实体Bean。

DAL4j can be useful for scenarios where there is an existing database schema but a technology other that JPA is used by applications to interact with the database. DAL4j可用于存在现有数据库模式的情况,但其他技术可由应用程序用于与数据库交互。 DAL4j can provide an easy way to migrate your code base from other technologies such as JDBC or Hibernate to JPA. DAL4j可以提供一种简单的方法将代码库从其他技术(如JDBC或Hibernate)迁移到JPA。

The beans generated can be 1 or two types: Simple or Framework. 生成的bean可以是1种或两种类型:Simple或Framework。 Simple beans are standard pojo classes managed by your application using JPA semantics. 简单bean是由您的应用程序使用JPA语义管理的标准pojo类。 Framework generated pojos use the DAL4j framework DAO generic to simplify CRUD operations. 框架生成的pojos使用DAL4j框架DAO泛型来简化CRUD操作。

DAL4j provides optional hooks to allow you integrate encryption/decryption of data fields that must be encrypted in the database. DAL4j提供可选的挂钩,允许您集成必须在数据库中加密的数据字段的加密/解密。

Last, DAL4j provides a set of Generic classes that can be used to simplify creation of Session Beans which perform CRUD operations using generated Entities. 最后,DAL4j提供了一组通用类,可用于简化会话Bean的创建,使用生成的实体执行CRUD操作。

I think you will find this article feasible.... 我想你会发现这篇文章可行....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM