* @param hibernateConfiguration The hibernate configuration
*/
public void execute(Configuration hibernateConfiguration) {
// First, determine the actions (if any) to be performed ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
final SchemaGenAction databaseAction = SchemaGenAction.interpret(
hibernateConfiguration.getProperty( AvailableSettings.SCHEMA_GEN_DATABASE_ACTION )
);
final SchemaGenAction scriptsAction = SchemaGenAction.interpret(
hibernateConfiguration.getProperty( AvailableSettings.SCHEMA_GEN_SCRIPTS_ACTION )
);
if ( databaseAction == SchemaGenAction.NONE && scriptsAction == SchemaGenAction.NONE ) {
// no actions needed
log.debug( "No actions specified; doing nothing" );
return;
}
// Figure out the JDBC Connection context, if any ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
final JdbcConnectionContext jdbcConnectionContext = determineAppropriateJdbcConnectionContext(
hibernateConfiguration,
serviceRegistry
);
try {
final Dialect dialect = determineDialect( jdbcConnectionContext, hibernateConfiguration, serviceRegistry );
// determine sources ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
final List<GenerationSource> createSourceList = databaseAction.includesCreate() || scriptsAction.includesCreate()
? buildCreateSourceList( hibernateConfiguration, dialect )
: Collections.<GenerationSource>emptyList();
final List<GenerationSource> dropSourceList = databaseAction.includesDrop() || scriptsAction.includesDrop()
? buildDropSourceList( hibernateConfiguration, dialect )
: Collections.<GenerationSource>emptyList();
// determine targets ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
final GenerationTarget databaseTarget = new GenerationTargetToDatabase( jdbcConnectionContext, databaseAction );
final Object createScriptTargetSetting = hibernateConfiguration.getProperties().get(
AvailableSettings.SCHEMA_GEN_SCRIPTS_CREATE_TARGET
);
final Object dropScriptTargetSetting = hibernateConfiguration.getProperties().get(
AvailableSettings.SCHEMA_GEN_SCRIPTS_DROP_TARGET
);
final GenerationTarget scriptsTarget = new GenerationTargetToScript(
interpretScriptTargetSetting(
createScriptTargetSetting,
scriptsAction.includesCreate(),
AvailableSettings.SCHEMA_GEN_SCRIPTS_CREATE_TARGET
),
interpretScriptTargetSetting(
dropScriptTargetSetting,
scriptsAction.includesDrop(),
AvailableSettings.SCHEMA_GEN_SCRIPTS_DROP_TARGET
),
scriptsAction
);