throws SQLException
{
String schemaName = this._state.schemaName().get();
SQLVendor vendor = this._vendor;
ModificationFactory m = vendor.getModificationFactory();
TableReferenceFactory t = vendor.getTableReferenceFactory();
LiteralFactory l = vendor.getLiteralFactory();
// @formatter:off
PreparedStatement ps = connection.prepareStatement(
vendor.toString(
m.insert()
.setTableName( t.tableName( schemaName, ENTITY_TYPES_TABLE_NAME ) )
.setColumnSource( m.columnSourceByValues()
.addValues( l.param(), l.param() )
.createExpression()
)
.createExpression()
)
);
try
{
Set<String> insertedTypeNames = new HashSet<>();
for( EntityDescriptor descriptor : appInfo.entityDescriptors.values() )
{
for( Class<?> entityType : descriptor.types() )
{
String entityTypeName = entityType.getName();
if( !insertedTypeNames.contains( entityTypeName ) )
{
long pk = tablePKs.get( ENTITY_TYPES_TABLE_NAME );
ps.setInt( 1, (int) pk );
ps.setString( 2, entityTypeName );
ps.executeUpdate();
this._state.entityTypePKs().get().put( entityTypeName, (int) pk );
// this._state.entityTypeInfos().get().put( entityTypeName, new EntityTypeInfo( descriptor, (int) pk ) );
tablePKs.put( ENTITY_TYPES_TABLE_NAME, pk + 1 );
}
}
}
}
finally
{
SQLUtil.closeQuietly( ps );
}
ps = connection.prepareStatement(
vendor.toString(
m.insert()
.setTableName( t.tableName( schemaName, USED_CLASSES_TABLE_NAME ) )
.setColumnSource( m.columnSourceByValues()
.addValues( l.param(), l.param() )
.createExpression()
)
.createExpression()
)
);
try
{
for( CompositeDescriptorInfo descInfo : appInfo.usedValueComposites )
{
String vDescStr = compositeDescriptorToString( descInfo.layer, descInfo.module, descInfo.composite );
long pk = tablePKs.get( USED_CLASSES_TABLE_NAME );
ps.setInt( 1, (int) pk );
ps.setString( 2, vDescStr );
ps.executeUpdate();
this._state.usedClassesPKs().get().put( descInfo.composite, (int) pk );
tablePKs.put( USED_CLASSES_TABLE_NAME, pk + 1 );
}
}
finally
{
SQLUtil.closeQuietly( ps );
}
ps = connection.prepareStatement(
vendor.toString(
m.insert()
.setTableName( t.tableName( schemaName, ENUM_LOOKUP_TABLE_NAME ) )
.setColumnSource( m.columnSourceByValues()
.addValues( l.param(), l.param() )
.createExpression()
)
.createExpression()
)