Hibernate Pojo Generator

0.9.5 LGPL (GNU Lesser General Public License)    
  not rated
Java source code generator





Hibernate Pojo Generator is a program that generates all the Java code necessary to access a database via Hibernate Annotations (+ Spring) including JUnit tests (1 per table) that are able to run immediately without further customizations.

What does it do?

Given an accessible database schema, the Hibernate POJO Generator produces all the Java code necessary to access each field in each table via the Hibernate persistence framework. Additionally, the generator also creates all the necessary helper classes and test units for each component.

How does it work?

The generator uses JDBC to look at your database metadata to obtain the relationships between the tables, field types and so on. Once this is done, it constructs an object model representing the tables in the java world and thereafter uses Velocity as a templating engine to actually write out your source code.

The whole process, usually lasting just several seconds, is completely automated and requires no further interaction on your part.

What about the generated code?

A lot of work has gone into ensuring the resultant code is free from any errors, warnings or broken conventions. At the end of the run, your target folder will contain:

 * A class for each table in your database
 * A Data Access Object (+ interface) to access that table
 * Enumeration objects pertaining to that class
 * Data factories
 * JUnit v4 test case per table
 * All the relevant hibernate and spring configuration files
 * A data services layer containing static methods to access your data (load(..), save(..), etc)
 * Other minor stuff like Maven POM files and Ant build files.

Of course, you always have access to both the source code as well as the velocity template files.

I have business logic code...

Keep that in your own services layer. Remember that the generator will build your data layer for you, it is up to your application to provide higher level abstractions for the rest of your codebase. The code generated is meant to be completely overwritten on each database change; indeed it is recommended that you script your changes in such a way so as to regenerate your data layer automatically on each change.
Last updated on November 9th, 2008

0 User reviews so far.