Exemplo n.º 1
0
  /** Method to initialise the sequence table used for storing the sequence values. */
  protected void initialiseSequenceTable() {
    // Set catalog/schema name (using properties, and if not specified using the values for the
    // table)
    String catalogName = properties.getProperty("sequence-catalog-name");
    if (catalogName == null) {
      catalogName = properties.getProperty("catalog-name");
    }
    String schemaName = properties.getProperty("sequence-schema-name");
    if (schemaName == null) {
      schemaName = properties.getProperty("schema-name");
    }
    String tableName =
        (properties.getProperty("sequence-table-name") == null
            ? DEFAULT_TABLE_NAME
            : properties.getProperty("sequence-table-name"));

    RDBMSStoreManager storeMgr = (RDBMSStoreManager) this.storeMgr;
    DatastoreAdapter dba = storeMgr.getDatastoreAdapter();
    DatastoreIdentifier identifier = storeMgr.getIdentifierFactory().newTableIdentifier(tableName);
    if (dba.supportsOption(DatastoreAdapter.CATALOGS_IN_TABLE_DEFINITIONS) && catalogName != null) {
      identifier.setCatalogName(catalogName);
    }
    if (dba.supportsOption(DatastoreAdapter.SCHEMAS_IN_TABLE_DEFINITIONS) && schemaName != null) {
      identifier.setSchemaName(schemaName);
    }

    DatastoreClass table = storeMgr.getDatastoreClass(identifier);
    if (table != null) {
      sequenceTable = (SequenceTable) table;
    } else {
      String sequenceNameColumnName = DEFAULT_SEQUENCE_COLUMN_NAME;
      String nextValColumnName = DEFAULT_NEXTVALUE_COLUMN_NAME;
      if (properties.getProperty("sequence-name-column-name") != null) {
        sequenceNameColumnName = properties.getProperty("sequence-name-column-name");
      }
      if (properties.getProperty("sequence-nextval-column-name") != null) {
        nextValColumnName = properties.getProperty("sequence-nextval-column-name");
      }
      sequenceTable =
          new SequenceTable(identifier, storeMgr, sequenceNameColumnName, nextValColumnName);
      sequenceTable.initialize(storeMgr.getNucleusContext().getClassLoaderResolver(null));
    }
  }