use of org.datanucleus.store.rdbms.valuegenerator.SequenceTable in project datanucleus-rdbms by datanucleus.
the class RDBMSStoreManager method addSequenceTableForMetaData.
protected void addSequenceTableForMetaData(MetaData md, ClassLoaderResolver clr, Set<String> seqTablesGenerated) {
String catName = null;
String schName = null;
String tableName = TableGenerator.DEFAULT_TABLE_NAME;
String seqColName = TableGenerator.DEFAULT_SEQUENCE_COLUMN_NAME;
String nextValColName = TableGenerator.DEFAULT_NEXTVALUE_COLUMN_NAME;
if (md.hasExtension(ValueGenerator.PROPERTY_SEQUENCETABLE_CATALOG)) {
catName = md.getValueForExtension(ValueGenerator.PROPERTY_SEQUENCETABLE_CATALOG);
}
if (md.hasExtension(ValueGenerator.PROPERTY_SEQUENCETABLE_SCHEMA)) {
schName = md.getValueForExtension(ValueGenerator.PROPERTY_SEQUENCETABLE_SCHEMA);
}
if (md.hasExtension(ValueGenerator.PROPERTY_SEQUENCETABLE_TABLE)) {
tableName = md.getValueForExtension(ValueGenerator.PROPERTY_SEQUENCETABLE_TABLE);
}
if (md.hasExtension(ValueGenerator.PROPERTY_SEQUENCETABLE_NAME_COLUMN)) {
seqColName = md.getValueForExtension(ValueGenerator.PROPERTY_SEQUENCETABLE_NAME_COLUMN);
}
if (md.hasExtension(ValueGenerator.PROPERTY_SEQUENCETABLE_NEXTVAL_COLUMN)) {
nextValColName = md.getValueForExtension(ValueGenerator.PROPERTY_SEQUENCETABLE_NEXTVAL_COLUMN);
}
if (!seqTablesGenerated.contains(tableName)) {
ManagedConnection mconn = connectionMgr.getConnection(TransactionIsolation.NONE);
Connection conn = (Connection) mconn.getConnection();
try {
DatastoreIdentifier tableIdentifier = identifierFactory.newTableIdentifier(tableName);
if (catName != null) {
tableIdentifier.setCatalogName(catName);
}
if (schName != null) {
tableIdentifier.setSchemaName(schName);
}
SequenceTable seqTable = new SequenceTable(tableIdentifier, this, seqColName, nextValColName);
seqTable.initialize(clr);
seqTable.exists(conn, true);
} catch (Exception e) {
} finally {
mconn.release();
}
seqTablesGenerated.add(tableName);
}
}
Aggregations