Question

I would like to know if there are any tools to automatically generate EJB3 Entity Beans(for JPA) from a database schema.

Thanks.

Was it helpful?

Solution

Dali supports top-down, bottom-up (this is what you're looking for), and meet-in-the-middle development approaches.

OTHER TIPS

Some of IDs have such feature, for example NetBeans

OpenJPA has a tool which will generate your Entity definitions.

From the OpenJPA user manual:

OpenJPA includes a reverse mapping tool for generating persistent class definitions, complete with metadata, from an existing database schema. 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 ”. The reverse mapping tool, however, can give you an excellent starting point from which to grow your persistent classes.

No IDE required!

-Rick

I have a solution for you i.e 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 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 can provide an easy way to migrate your code base from other technologies such as JDBC or Hibernate to JPA.

The beans generated can be 1 or two types: Simple or Framework. Simple beans are standard pojo classes managed by your application using JPA semantics. Framework generated pojos use the DAL4j framework DAO generic to simplify CRUD operations.

DAL4j provides optional hooks to allow you integrate encryption/decryption of data fields that must be encrypted in the database.

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.

I think you will find this article feasible....

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top