Class BaseTable
- java.lang.Object
-
- migratedb.v1.core.internal.database.base.BaseSchemaObject
-
- migratedb.v1.core.internal.database.base.BaseTable
-
- All Implemented Interfaces:
SchemaObject,Table
- 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 extends BaseSchemaObject implements Table
-
-
Field Summary
Fields Modifier and Type Field Description protected intlockDepthKeeps 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
jdbcTemplate
-
-
Constructor Summary
Constructors Constructor Description BaseTable(JdbcTemplate jdbcTemplate, Database database, Schema schema, String name)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract booleandoExists()Checks whether this table exists.protected abstract voiddoLock()Locks this table in this schema using a read/write pessimistic lock until the end of the current transaction.protected voiddoUnlock()For databases that require an explicit unlocking, not an implicit end-of-transaction one.booleanexists()protected booleanexists(@Nullable Schema catalog, @Nullable Schema schema, String table, String... tableTypes)Checks whether the database contains a table matching the given criteria.voidlock()Locks this table in this schema using a read/write pessimistic lock until the end of the current transaction.voidunlock()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
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
getDatabase, getName, getSchema, toString
-
-
-
-
Constructor Detail
-
BaseTable
public BaseTable(JdbcTemplate jdbcTemplate, Database database, Schema 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 Detail
-
doExists
protected abstract boolean doExists() throws SQLExceptionChecks whether this table exists.- Throws:
SQLException- when the check failed.
-
exists
protected boolean exists(@Nullable Schema catalog, @Nullable 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:TableLocks this table in this schema using a read/write pessimistic lock until the end of the current transaction. Note thatunlock()still needs to be called even if your database unlocks the table implicitly (in which casedoUnlock()may be a no-op) in order to maintain the lock count correctly.
-
doLock
protected abstract void doLock() throws SQLExceptionLocks this table in this schema using a read/write pessimistic lock until the end of the current transaction. Note thatunlock()still needs to be called even if your database unlocks the table implicitly (in which casedoUnlock()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:TableFor databases that require an explicit unlocking, not an implicit end-of-transaction one.
-
doUnlock
protected void doUnlock() throws SQLExceptionFor 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.
-
-