Search in sources :

Example 1 with SequenceTable

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);
    }
}
Also used : DatastoreIdentifier(org.datanucleus.store.rdbms.identifier.DatastoreIdentifier) Connection(java.sql.Connection) NucleusConnection(org.datanucleus.store.NucleusConnection) ManagedConnection(org.datanucleus.store.connection.ManagedConnection) SequenceTable(org.datanucleus.store.rdbms.valuegenerator.SequenceTable) ManagedConnection(org.datanucleus.store.connection.ManagedConnection) MacroString(org.datanucleus.util.MacroString) SQLException(java.sql.SQLException) NucleusDataStoreException(org.datanucleus.exceptions.NucleusDataStoreException) IOException(java.io.IOException) NucleusException(org.datanucleus.exceptions.NucleusException) UnsupportedDataTypeException(org.datanucleus.store.rdbms.exceptions.UnsupportedDataTypeException) NoTableManagedException(org.datanucleus.store.rdbms.exceptions.NoTableManagedException) NucleusUserException(org.datanucleus.exceptions.NucleusUserException) IncompatibleFieldTypeException(org.datanucleus.store.types.IncompatibleFieldTypeException)

Aggregations

IOException (java.io.IOException)1 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 NucleusDataStoreException (org.datanucleus.exceptions.NucleusDataStoreException)1 NucleusException (org.datanucleus.exceptions.NucleusException)1 NucleusUserException (org.datanucleus.exceptions.NucleusUserException)1 NucleusConnection (org.datanucleus.store.NucleusConnection)1 ManagedConnection (org.datanucleus.store.connection.ManagedConnection)1 NoTableManagedException (org.datanucleus.store.rdbms.exceptions.NoTableManagedException)1 UnsupportedDataTypeException (org.datanucleus.store.rdbms.exceptions.UnsupportedDataTypeException)1 DatastoreIdentifier (org.datanucleus.store.rdbms.identifier.DatastoreIdentifier)1 SequenceTable (org.datanucleus.store.rdbms.valuegenerator.SequenceTable)1 IncompatibleFieldTypeException (org.datanucleus.store.types.IncompatibleFieldTypeException)1 MacroString (org.datanucleus.util.MacroString)1