The 2nd secret to DBvolution is the simple way you can generate the data model
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
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
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