Class BaseTable<D extends Database<?>,S extends Schema<?,?>>

java.lang.Object
migratedb.v1.core.internal.database.base.BaseSchemaObject<D,S>
migratedb.v1.core.internal.database.base.BaseTable<D,S>
All Implemented Interfaces:
SchemaObject<D,S>, Table<D,S>
Direct Known Subclasses:
BigQueryTable, CockroachDBTable, DB2Table, DerbyTable, FirebirdTable, H2Table, HSQLDBTable, IgniteThinTable, InformixTable, MySQLTable, OracleTable, PostgreSQLTable, RedshiftTable, SAPHANATable, SnowflakeTable, SpannerTable, SQLiteTable, SQLServerTable, SybaseASETable

public abstract class BaseTable<D extends Database<?>,S extends Schema<?,?>> extends BaseSchemaObject<D,S> implements Table<D,S>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int
    Keeps track of the locks on a table since calls to lock the table can be nested.

    Fields inherited from class migratedb.v1.core.internal.database.base.BaseSchemaObject

    database, jdbcTemplate, name, schema
  • Constructor Summary

    Constructors
    Constructor
    Description
    BaseTable(JdbcTemplate jdbcTemplate, D database, S schema, String name)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract boolean
    Checks whether this table exists.
    protected abstract void
    Locks this table in this schema using a read/write pessimistic lock until the end of the current transaction.
    protected void
    For databases that require an explicit unlocking, not an implicit end-of-transaction one.
    boolean
     
    protected boolean
    exists(Schema<?,?> catalog, Schema<?,?> schema, String table, String... tableTypes)
    Checks whether the database contains a table matching the given criteria.
    void
    Locks this table in this schema using a read/write pessimistic lock until the end of the current transaction.
    void
    For databases that require an explicit unlocking, not an implicit end-of-transaction one.

    Methods inherited from class migratedb.v1.core.internal.database.base.BaseSchemaObject

    doDrop, drop, getDatabase, getName, getSchema, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface migratedb.v1.core.api.internal.database.base.SchemaObject

    drop, getDatabase, getName, getSchema, toString
  • Field Details

    • lockDepth

      protected int lockDepth
      Keeps track of the locks on a table since calls to lock the table can be nested.
  • Constructor Details

    • BaseTable

      public BaseTable(JdbcTemplate jdbcTemplate, D database, S schema, String name)
      Parameters:
      jdbcTemplate - The JDBC template for communicating with the DB.
      database - The database-specific support.
      schema - The schema this table lives in.
      name - The name of the table.
  • Method Details

    • exists

      public boolean exists()
      Specified by:
      exists in interface Table<D extends Database<?>,S extends Schema<?,?>>
    • doExists

      protected abstract boolean doExists() throws SQLException
      Checks whether this table exists.
      Throws:
      SQLException - when the check failed.
    • exists

      protected boolean exists(Schema<?,?> catalog, Schema<?,?> schema, String table, String... tableTypes) throws SQLException
      Checks whether the database contains a table matching the given criteria.
      Parameters:
      catalog - The catalog where the table resides. (optional)
      schema - The schema where the table resides. (optional)
      table - The name of the table. (optional)
      tableTypes - The types of table to look for (e.g. TABLE). (optional)
      Throws:
      SQLException - when the check failed.
    • lock

      public void lock()
      Description copied from interface: Table
      Locks this table in this schema using a read/write pessimistic lock until the end of the current transaction. Note that unlock() still needs to be called even if your database unlocks the table implicitly (in which case doUnlock() may be a no-op) in order to maintain the lock count correctly.
      Specified by:
      lock in interface Table<D extends Database<?>,S extends Schema<?,?>>
    • doLock

      protected abstract void doLock() throws SQLException
      Locks this table in this schema using a read/write pessimistic lock until the end of the current transaction. Note that unlock() still needs to be called even if your database unlocks the table implicitly (in which case doUnlock() may be a no-op) in order to maintain the lock count correctly.
      Throws:
      SQLException - when this table in this schema could not be locked.
    • unlock

      public void unlock()
      Description copied from interface: Table
      For databases that require an explicit unlocking, not an implicit end-of-transaction one.
      Specified by:
      unlock in interface Table<D extends Database<?>,S extends Schema<?,?>>
    • doUnlock

      protected void doUnlock() throws SQLException
      For databases that require an explicit unlocking, not an implicit end-of-transaction one.
      Throws:
      SQLException - when this table in this schema could not be unlocked.