{
final String tableName = keyTypes[i] + "_pk";
final String columnPKName = keyTypes[i] + "_pk";
final String columnFKName = keyTypes[i] + "_fk";
final String columnType = keyTypes[i] + ( keyCreationArgs[i] != null ? keyCreationArgs[i] : "" );
m_database.createTable( new HsqlTableDescriptor( tableName,
new HsqlColumnDescriptor[] {
new HsqlColumnDescriptor( columnPKName, columnType, HsqlColumnDescriptor.PRIMARY ),
new HsqlColumnDescriptor( "content", "varchar(50)" )
}
) );
// insert a few rows
StringBuffer sql = new StringBuffer();
sql.append( "INSERT INTO \"" );
sql.append( tableName );
sql.append( "\" VALUES (?, ?)");
XPreparedStatement statement = connection.prepareStatement( sql.toString() );
XParameters statementParameters = UnoRuntime.queryInterface( XParameters.class, statement );
final String[] keyValues = impl_getTypedValue( keyTypes[i], 0 );
for ( int row=0; row<displayValues.length; ++row )
{
statementParameters.setString( 1, keyValues[row] );
statementParameters.setString( 2, displayValues[row] );
statement.execute();
}
// remember a column descriptor for later creation of the table with the foreign keys
foreignKeyColumns.add( new HsqlColumnDescriptor( columnFKName, columnType, HsqlColumnDescriptor.REQUIRED,
tableName, columnPKName ) );
// remember the data to fill into this table
foreignKeyValues.add( keyValues );
foreignKeyInsertSQL.append( ", ?" );
}
// create the table taking all those foreign keys
m_database.createTable( new HsqlTableDescriptor( m_foreignKeyTableName, foreignKeyColumns.toArray( new HsqlColumnDescriptor[0] ) ) );
// fill in some data
foreignKeyInsertSQL.append( ")" );
XPreparedStatement statement = connection.prepareStatement( foreignKeyInsertSQL.toString() );
XParameters statementParameters = UnoRuntime.queryInterface( XParameters.class, statement );
for ( int row=0; row<2; ++row )