Package net.sf.basedb.core.hibernate
Class SchemaGenerator
- java.lang.Object
-
- net.sf.basedb.core.hibernate.SchemaGenerator
-
- All Implemented Interfaces:
Work
public class SchemaGenerator extends Object implements Work
Replaces the Hibernate SchemaExport and SchemaUpdate tools. We need this to be able to intercept and modify some of the SQL statments that Hibernate generates since they don't always work as expected. Since Hibernate 5 we only trust table and column definitions. Foreign keys and indexes are created withDbIndexWork
. Hibernate generate "not null" constraints for columns that are added to existing tables and we don't want that.- Since:
- 2.16
- Author:
- Nicklas
- Last modified
- $Date: 2018-11-05 15:01:50 +0100 (må, 05 nov 2018) $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
SchemaGenerator.CollectSqlTarget
Helper class used for collecting SQL statements generated by Hibernate schema creation/update tools.static class
SchemaGenerator.Mode
The installation mode.static class
SchemaGenerator.SqlStatement
-
Field Summary
Fields Modifier and Type Field Description private DbEngine
dbEngine
private Dialect
dialect
private List<String>
ignoredSql
private static org.slf4j.Logger
log
private Metadata
metadata
private SchemaGenerator.Mode
mode
private ProgressReporter
progress
-
Constructor Summary
Constructors Constructor Description SchemaGenerator(Metadata metadata, Dialect dialect, DbEngine dbEngine, SchemaGenerator.Mode mode, ProgressReporter progress)
Create a new schema generator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
execute(Connection connection)
List<String>
getIgnoredSql()
Get a list with the SQL statements that was ignored in the last run.
-
-
-
Field Detail
-
log
private static final org.slf4j.Logger log
-
metadata
private final Metadata metadata
-
dialect
private final Dialect dialect
-
dbEngine
private final DbEngine dbEngine
-
mode
private final SchemaGenerator.Mode mode
-
progress
private final ProgressReporter progress
-
-
Constructor Detail
-
SchemaGenerator
public SchemaGenerator(Metadata metadata, Dialect dialect, DbEngine dbEngine, SchemaGenerator.Mode mode, ProgressReporter progress)
Create a new schema generator.- Parameters:
metadata
- Information about current configurationdialect
- The dialect of the database we are connecting todbEngine
- The DbEngine for the database we are connecting tomode
- The installation modeprogress
- An optional progress reporter
-
-
Method Detail
-
execute
public void execute(Connection connection) throws SQLException
- Specified by:
execute
in interfaceWork
- Throws:
SQLException
-
-