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 with
DbIndexWork
.
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: 2023-03-31 09:53:31 +0200 (Fri, 31 Mar 2023) $
-
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
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 Details
-
log
private static final org.slf4j.Logger log -
metadata
-
dialect
-
dbEngine
-
mode
-
progress
-
ignoredSql
-
-
Constructor Details
-
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 Details
-
execute
- Specified by:
execute
in interfaceWork
- Throws:
SQLException
-
getIgnoredSql
Get a list with the SQL statements that was ignored in the last run.- Returns:
- A list or null if the generator hasn't been executed
- Since:
- 3.1
-