Class BaseSession
- java.lang.Object
-
- migratedb.v1.core.internal.database.base.BaseSession
-
- All Implemented Interfaces:
AutoCloseable,Session
- Direct Known Subclasses:
BigQuerySession,CockroachDBSession,DB2Session,DerbySession,FirebirdSession,H2Session,HSQLDBSession,IgniteThinSession,InformixSession,MySQLSession,OracleSession,PostgreSQLSession,RedshiftSession,SAPHANASession,SnowflakeSession,SpannerSession,SQLiteSession,SQLServerSession,SybaseASESession
public abstract class BaseSession extends Object implements Session
-
-
Field Summary
Fields Modifier and Type Field Description protected JdbcTemplatejdbcTemplateprotected StringoriginalSchemaNameOrSearchPath
-
Constructor Summary
Constructors Modifier Constructor Description protectedBaseSession(Database database, Connection connection)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidchangeCurrentSchemaTo(Schema schema)Sets the current schema, which is the default owner of new database objects.voidclose()protected voiddoChangeCurrentSchemaOrSearchPathTo(String schemaNameOrSearchPath)protected SchemadoGetCurrentSchema()protected voiddoRestoreOriginalState()SchemagetCurrentSchema()Retrieves the current schema, which is the default owner of new database objects.protected abstract StringgetCurrentSchemaNameOrSearchPath()DatabasegetDatabase()ConnectiongetJdbcConnection()JdbcTemplategetJdbcTemplate()<T> Tlock(Table table, Callable<T> callable)Locks this table and executes this callable.voidrestoreOriginalState()Undoes all changes to database settings and variables whose scope is bound to the lifetime of the JDBC connection.
-
-
-
Field Detail
-
jdbcTemplate
protected JdbcTemplate jdbcTemplate
-
originalSchemaNameOrSearchPath
protected final String originalSchemaNameOrSearchPath
-
-
Constructor Detail
-
BaseSession
protected BaseSession(Database database, Connection connection)
-
-
Method Detail
-
getCurrentSchemaNameOrSearchPath
protected abstract String getCurrentSchemaNameOrSearchPath() throws SQLException
- Throws:
SQLException- when the current schema name or search path could not be retrieved.
-
getCurrentSchema
public Schema getCurrentSchema()
Description copied from interface:SessionRetrieves the current schema, which is the default owner of new database objects. In many databases, the current schema is also used to lookup tables whenever the schema qualifier is omitted.- Specified by:
getCurrentSchemain interfaceSession
-
doGetCurrentSchema
protected Schema doGetCurrentSchema() throws SQLException
- Throws:
SQLException
-
changeCurrentSchemaTo
public void changeCurrentSchemaTo(Schema schema)
Description copied from interface:SessionSets the current schema, which is the default owner of new database objects. In many databases, the current schema is also used to lookup tables whenever the schema qualifier is omitted.- Specified by:
changeCurrentSchemaToin interfaceSession
-
doChangeCurrentSchemaOrSearchPathTo
protected void doChangeCurrentSchemaOrSearchPathTo(String schemaNameOrSearchPath) throws SQLException
- Parameters:
schemaNameOrSearchPath- The new current schema for this connection.- Throws:
SQLException- when the current schema could not be set.
-
lock
public <T> T lock(Table table, Callable<T> callable)
Description copied from interface:SessionLocks this table and executes this callable.
-
getJdbcTemplate
public final JdbcTemplate getJdbcTemplate()
- Specified by:
getJdbcTemplatein interfaceSession
-
close
public final void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSession
-
restoreOriginalState
public final void restoreOriginalState()
Description copied from interface:SessionUndoes all changes to database settings and variables whose scope is bound to the lifetime of the JDBC connection. An example of such state is thesearch_pathsetting of PostgreSQL. Methods that may change state are:Will only undo changes that have been made through this object. Changes made by migration scripts are not accounted for.
- Specified by:
restoreOriginalStatein interfaceSession
-
doRestoreOriginalState
protected void doRestoreOriginalState() throws SQLException- Throws:
SQLException
-
getJdbcConnection
public final Connection getJdbcConnection()
- Specified by:
getJdbcConnectionin interfaceSession
-
getDatabase
public Database getDatabase()
-
-