Create Your Data Model Easily




Let DBvolution do the work for you

DBTableClassGenerator: Fast Data Model

The 2nd secret to DBvolution is the simple way you can generate the data model

DBTableClassGenerator.generateClasses(
yourDBDatabaseObject,
"com.companyname.projectname",
"C:/Projects/projectname/src/main/java"
);

DBvolution uses actual java classes to represent the data model. These are designed to be easy to write by hand but, if you already have a database schema, a faster, safer, and easier method is provided by DBTableClassGenerator

DBRow subclasses will be generated that capture the table and column names, associate them with class variables, give the variables appropriate DBvolution data type to bridge the Object/Relational divide, and mark any primary or foreign keys found. This magic is accomplished using the database schema itself, so you know it's correct

All generated classes are clear and concise as shown here.

DBTableClassGenerator provides several methods for generating the classes required. The simplest is shown below. Use the DBDatabase instance, supply the package name you want the classes to be in, and the base for the source tree. The class generator will create all the class at that location ready for compiling without any changes

DBTableClassGenerator.generateClasses(
existingDatabase,
"com.companyname.projectname",
"C:/Projects/projectname/src/main/java"
);

Your IDE can display the fields and assist writing your business logic because the classes are permanent and compiled

The classes are only generated once so the code is robust and maintenance is easy because classes are formatted and use only simple DBvolution classes. You can add methods and refactor field and class names freely to improve the functionality and readability. The annotations generated are optional but protect the database schema information from standard refactoring techniques.

If your database schema has a naming convention, you can improve the behaviour of DBTableClassGenerator by adding custom Recognisors. These help with the common task of recognising primary and foreign keys which are sometimes not properly designated in the schema. Examples of recognisors are included in the nz.co.gregs.dbvolution.example package

DBTableClassGenerator.generateClasses(
batInstance,
"nz.co.gregs.schema",
"C:/Projects/Other/Gregs/src/main/java",
new UIDBasedPKRecognisor(),
new FKBasedFKRecognisor()
);

When you want DB to be easier and faster...

Get DBvolution from GitHub or Maven

DBvolution is the gateway to your database and high-speed querying
  Contact us now for details
  +64 27 444 5201
Twitter
Support us on Patreon