public class DBTableClassGenerator extends Object
DBvolution data model classes (DBRow subclasses) are designed to be easy to create and modify. However with a complex existing database it can be easier to use this class to generate the data model and then add the details.
Support DBvolution at Patreon
| Modifier and Type | Class and Description |
|---|---|
static class |
DBTableClassGenerator.Options |
| Modifier and Type | Method and Description |
|---|---|
static void |
generateClasses(DBDatabase database,
String packageName,
String baseDirectory)
Creates DBTableRow classes corresponding to all the tables and views
accessible to the user specified in the database supplied.
|
static void |
generateClasses(DBDatabase database,
String packageName,
String baseDirectory,
DBTableClassGenerator.Options options)
Creates DBTableRow classes corresponding to all the tables and views
accessible to the user specified in the database supplied.
|
static void |
generateClasses(DBDatabase database,
String packageName,
String baseDirectory,
Long versionNumber)
Creates DBTableRow classes corresponding to all the tables and views
accessible to the user specified in the database supplied.
|
static List<DBTableClass> |
generateClassesOfTables(DBDatabase database,
String packageName,
DBTableClassGenerator.Options options)
Generate the required Java classes for all the Tables on the database.
|
static List<DBTableClass> |
generateClassesOfViews(DBDatabase database,
String packageName,
DBTableClassGenerator.Options options)
Generate the required Java classes for all the Views on the database.
|
static String |
toClassCase(String s)
returns a good guess at the java CLASS version of a DB field name.
|
public static void generateClasses(DBDatabase database, String packageName, String baseDirectory) throws SQLException, FileNotFoundException, IOException
Classes are placed in the correct subdirectory of the base directory as defined by the package name supplied.
Convenience method which calls generateClasses(jdbcURL, username,
password, packageName, 1L, baseDirectory,new PrimaryKeyRecognisor(),new
ForeignKeyRecognisor());
1 Database exceptions may be thrown
database - databasepackageName - packageNamebaseDirectory - baseDirectorySQLException - java.sql.SQLExceptionFileNotFoundException - java.io.FileNotFoundExceptionIOException - java.io.IOExceptionpublic static void generateClasses(DBDatabase database, String packageName, String baseDirectory, Long versionNumber) throws SQLException, FileNotFoundException, IOException
Classes are placed in the correct subdirectory of the base directory as defined by the package name supplied.
Convenience method which calls generateClasses(jdbcURL,username,password,packageName,baseDirectory,new
PrimaryKeyRecognisor(),new ForeignKeyRecognisor());
database - databaseversionNumber - - the value to use for serialVersionUID
1 Database exceptions may be thrownpackageName - packageNamebaseDirectory - baseDirectorySQLException - java.sql.SQLExceptionFileNotFoundException - java.io.FileNotFoundExceptionIOException - java.io.IOExceptionpublic static void generateClasses(DBDatabase database, String packageName, String baseDirectory, DBTableClassGenerator.Options options) throws SQLException, FileNotFoundException, IOException
Classes are placed in the correct subdirectory of the base directory as defined by the package name supplied.
Primary keys and foreign keys are created based on the definitions within the database and the results from the PK and FK recognisors.
Database exceptions may be thrown
database - databasepackageName - packageNamebaseDirectory - baseDirectoryoptions - SQLException - java.sql.SQLExceptionFileNotFoundException - java.io.FileNotFoundExceptionIOException - java.io.IOExceptionpublic static List<DBTableClass> generateClassesOfTables(DBDatabase database, String packageName, DBTableClassGenerator.Options options) throws SQLException
Connects to the database using the DBDatabase instance supplied and generates class for the tables it can find.
Classes will be in the package supplied, serialVersionUID will be set to
the version number supplied and the supplied PrimaryKeyRecognisor
and ForeignKeyRecognisor will be used.
database - databasepackageName - packageNameoptions - Support DBvolution at Patreon
SQLException - java.sql.SQLExceptionpublic static List<DBTableClass> generateClassesOfViews(DBDatabase database, String packageName, DBTableClassGenerator.Options options) throws SQLException
Connects to the database using the DBDatabase instance supplied and generates class for the views it can find.
Classes will be in the package supplied, serialVersionUID will be set to
the version number supplied and the supplied PrimaryKeyRecognisor
and ForeignKeyRecognisor will be used.
database - databasepackageName - packageNameoptions - Support DBvolution at Patreon
SQLException - java.sql.SQLExceptionCopyright © 2018. All Rights Reserved.