liquibase.snapshot.jvm
Class JdbcDatabaseSnapshotGenerator
java.lang.Object
liquibase.snapshot.jvm.JdbcDatabaseSnapshotGenerator
- All Implemented Interfaces:
- DatabaseSnapshotGenerator
- Direct Known Subclasses:
- DB2DatabaseSnapshotGenerator, DerbyDatabaseSnapshotGenerator, H2DatabaseSnapshotGenerator, HsqlDatabaseSnapshotGenerator, InformixDatabaseSnapshotGenerator, MSSQLDatabaseSnapshotGenerator, MySQLDatabaseSnapshotGenerator, OracleDatabaseSnapshotGenerator, PostgresDatabaseSnapshotGenerator, SQLiteDatabaseSnapshotGenerator, StandardJdbcDatabaseSnapshotGenerator
public abstract class JdbcDatabaseSnapshotGenerator
- extends Object
- implements DatabaseSnapshotGenerator
Method Summary |
protected void |
configureColumnType(Column column,
ResultSet rs)
Configuration of column's type. |
protected String |
convertColumnNameToDatabaseTableName(String columnName)
|
protected String |
convertFromDatabaseName(String objectName)
|
protected String |
convertPrimaryKeyName(String pkName)
|
protected String |
convertTableNameToDatabaseTableName(String tableName)
|
protected ForeignKeyConstraintType |
convertToForeignKeyConstraintType(int jdbcType)
|
DatabaseSnapshot |
createSnapshot(Database database,
String requestedSchema,
Set<DiffStatusListener> listeners)
|
protected ForeignKeyInfo |
fillForeignKeyInfo(ResultSet rs)
Fill foreign key information from the current register of a getImportedKeys resultset |
ForeignKey |
generateForeignKey(ForeignKeyInfo fkInfo,
Database database,
List<ForeignKey> fkList)
Generation of Foreign Key based on information about it. |
List<ForeignKey> |
getAdditionalForeignKeys(String schemaName,
Database database)
It finds only all database-specific Foreign Keys. |
Column |
getColumn(String schemaName,
String tableName,
String columnName,
Database database)
|
protected void |
getColumnTypeAndDefValue(Column columnInfo,
ResultSet rs,
Database database)
Method assigns correct column type and default value to Column object. |
Table |
getDatabaseChangeLogLockTable(Database database)
|
Table |
getDatabaseChangeLogTable(Database database)
|
int |
getDatabaseType(int type,
Database database)
|
ForeignKey |
getForeignKeyByForeignKeyTable(String schemaName,
String foreignKeyTableName,
String fkName,
Database database)
|
List<ForeignKey> |
getForeignKeys(String schemaName,
String foreignKeyTableName,
Database database)
|
protected DatabaseMetaData |
getMetaData(Database database)
|
Table |
getTable(String schemaName,
String tableName,
Database database)
|
boolean |
hasDatabaseChangeLogLockTable(Database database)
|
boolean |
hasDatabaseChangeLogTable(Database database)
|
boolean |
hasIndex(String schemaName,
String tableName,
String indexName,
Database database,
String columnNames)
|
boolean |
hasTable(String schemaName,
String tableName,
Database database)
|
boolean |
hasView(String schemaName,
String viewName,
Database database)
|
boolean |
isColumnAutoIncrement(Database database,
String schemaName,
String tableName,
String columnName)
|
protected void |
readColumns(DatabaseSnapshot snapshot,
String schema,
DatabaseMetaData databaseMetaData)
|
protected void |
readForeignKeyInformation(DatabaseSnapshot snapshot,
String schema,
DatabaseMetaData databaseMetaData)
|
protected void |
readIndexes(DatabaseSnapshot snapshot,
String schema,
DatabaseMetaData databaseMetaData)
|
protected void |
readPrimaryKeys(DatabaseSnapshot snapshot,
String schema,
DatabaseMetaData databaseMetaData)
|
protected void |
readSequences(DatabaseSnapshot snapshot,
String schema,
DatabaseMetaData databaseMetaData)
|
protected void |
readTables(DatabaseSnapshot snapshot,
String schema,
DatabaseMetaData databaseMetaData)
|
protected void |
readUniqueConstraints(DatabaseSnapshot snapshot,
String schema,
DatabaseMetaData databaseMetaData)
|
protected void |
readViews(DatabaseSnapshot snapshot,
String schema,
DatabaseMetaData databaseMetaData)
|
protected void |
updateListeners(String message)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JdbcDatabaseSnapshotGenerator
public JdbcDatabaseSnapshotGenerator()
convertTableNameToDatabaseTableName
protected String convertTableNameToDatabaseTableName(String tableName)
convertColumnNameToDatabaseTableName
protected String convertColumnNameToDatabaseTableName(String columnName)
getDatabaseChangeLogTable
public Table getDatabaseChangeLogTable(Database database)
throws DatabaseException
- Specified by:
getDatabaseChangeLogTable
in interface DatabaseSnapshotGenerator
- Throws:
DatabaseException
getDatabaseChangeLogLockTable
public Table getDatabaseChangeLogLockTable(Database database)
throws DatabaseException
- Specified by:
getDatabaseChangeLogLockTable
in interface DatabaseSnapshotGenerator
- Throws:
DatabaseException
hasDatabaseChangeLogTable
public boolean hasDatabaseChangeLogTable(Database database)
- Specified by:
hasDatabaseChangeLogTable
in interface DatabaseSnapshotGenerator
hasDatabaseChangeLogLockTable
public boolean hasDatabaseChangeLogLockTable(Database database)
- Specified by:
hasDatabaseChangeLogLockTable
in interface DatabaseSnapshotGenerator
hasTable
public boolean hasTable(String schemaName,
String tableName,
Database database)
- Specified by:
hasTable
in interface DatabaseSnapshotGenerator
hasView
public boolean hasView(String schemaName,
String viewName,
Database database)
- Specified by:
hasView
in interface DatabaseSnapshotGenerator
getTable
public Table getTable(String schemaName,
String tableName,
Database database)
throws DatabaseException
- Specified by:
getTable
in interface DatabaseSnapshotGenerator
- Throws:
DatabaseException
getColumn
public Column getColumn(String schemaName,
String tableName,
String columnName,
Database database)
throws DatabaseException
- Specified by:
getColumn
in interface DatabaseSnapshotGenerator
- Throws:
DatabaseException
configureColumnType
protected void configureColumnType(Column column,
ResultSet rs)
throws SQLException
- Configuration of column's type.
- Parameters:
column
- Column to configurers
- Result set, used as a property resource.
- Throws:
SQLException
- wrong Result Set content
createSnapshot
public DatabaseSnapshot createSnapshot(Database database,
String requestedSchema,
Set<DiffStatusListener> listeners)
throws DatabaseException
- Specified by:
createSnapshot
in interface DatabaseSnapshotGenerator
- Throws:
DatabaseException
getMetaData
protected DatabaseMetaData getMetaData(Database database)
throws SQLException
- Throws:
SQLException
readTables
protected void readTables(DatabaseSnapshot snapshot,
String schema,
DatabaseMetaData databaseMetaData)
throws SQLException,
DatabaseException
- Throws:
SQLException
DatabaseException
readViews
protected void readViews(DatabaseSnapshot snapshot,
String schema,
DatabaseMetaData databaseMetaData)
throws SQLException,
DatabaseException
- Throws:
SQLException
DatabaseException
convertFromDatabaseName
protected String convertFromDatabaseName(String objectName)
readColumns
protected void readColumns(DatabaseSnapshot snapshot,
String schema,
DatabaseMetaData databaseMetaData)
throws SQLException,
DatabaseException
- Throws:
SQLException
DatabaseException
getColumnTypeAndDefValue
protected void getColumnTypeAndDefValue(Column columnInfo,
ResultSet rs,
Database database)
throws SQLException,
DatabaseException
- Method assigns correct column type and default value to Column object.
This method should be database engine specific. JDBC implementation requires
database engine vendors to convert native DB types to java objects.
During conversion some metadata information are being lost or reported incorrectly via DatabaseMetaData objects.
This method, if necessary, must be overriden. It must go below DatabaseMetaData implementation and talk directly to database to get correct metadata information.
- Throws:
SQLException
DatabaseException
readForeignKeyInformation
protected void readForeignKeyInformation(DatabaseSnapshot snapshot,
String schema,
DatabaseMetaData databaseMetaData)
throws DatabaseException,
SQLException
- Throws:
DatabaseException
SQLException
hasIndex
public boolean hasIndex(String schemaName,
String tableName,
String indexName,
Database database,
String columnNames)
throws DatabaseException
- Specified by:
hasIndex
in interface DatabaseSnapshotGenerator
- Throws:
DatabaseException
getForeignKeyByForeignKeyTable
public ForeignKey getForeignKeyByForeignKeyTable(String schemaName,
String foreignKeyTableName,
String fkName,
Database database)
throws DatabaseException
- Specified by:
getForeignKeyByForeignKeyTable
in interface DatabaseSnapshotGenerator
- Throws:
DatabaseException
generateForeignKey
public ForeignKey generateForeignKey(ForeignKeyInfo fkInfo,
Database database,
List<ForeignKey> fkList)
throws DatabaseException
- Generation of Foreign Key based on information about it.
- Parameters:
fkInfo
- contains all needed properties of FKdatabase
- current databasefkList
- list of already generated keys
- Returns:
- generated Foreing Key
- Throws:
DatabaseException
- Database Exception
getAdditionalForeignKeys
public List<ForeignKey> getAdditionalForeignKeys(String schemaName,
Database database)
throws DatabaseException
- It finds only all database-specific Foreign Keys.
By default it returns an empty ArrayList.
- Parameters:
schemaName
- current shemaNamedatabase
- current database
- Returns:
- list of database-specific Foreing Keys
- Throws:
DatabaseException
- any kinds of SQLException errors
getForeignKeys
public List<ForeignKey> getForeignKeys(String schemaName,
String foreignKeyTableName,
Database database)
throws DatabaseException
- Specified by:
getForeignKeys
in interface DatabaseSnapshotGenerator
- Throws:
DatabaseException
fillForeignKeyInfo
protected ForeignKeyInfo fillForeignKeyInfo(ResultSet rs)
throws DatabaseException,
SQLException
- Fill foreign key information from the current register of a getImportedKeys resultset
- Parameters:
rs
- The resultset returned by getImportedKeys
- Returns:
- Foreign key information
- Throws:
DatabaseException
SQLException
convertToForeignKeyConstraintType
protected ForeignKeyConstraintType convertToForeignKeyConstraintType(int jdbcType)
throws DatabaseException
- Throws:
DatabaseException
readIndexes
protected void readIndexes(DatabaseSnapshot snapshot,
String schema,
DatabaseMetaData databaseMetaData)
throws DatabaseException,
SQLException
- Throws:
DatabaseException
SQLException
readPrimaryKeys
protected void readPrimaryKeys(DatabaseSnapshot snapshot,
String schema,
DatabaseMetaData databaseMetaData)
throws DatabaseException,
SQLException
- Throws:
DatabaseException
SQLException
convertPrimaryKeyName
protected String convertPrimaryKeyName(String pkName)
throws SQLException
- Throws:
SQLException
readUniqueConstraints
protected void readUniqueConstraints(DatabaseSnapshot snapshot,
String schema,
DatabaseMetaData databaseMetaData)
throws DatabaseException,
SQLException
- Throws:
DatabaseException
SQLException
readSequences
protected void readSequences(DatabaseSnapshot snapshot,
String schema,
DatabaseMetaData databaseMetaData)
throws DatabaseException
- Throws:
DatabaseException
updateListeners
protected void updateListeners(String message)
isColumnAutoIncrement
public boolean isColumnAutoIncrement(Database database,
String schemaName,
String tableName,
String columnName)
throws SQLException,
DatabaseException
- Throws:
SQLException
DatabaseException
getDatabaseType
public int getDatabaseType(int type,
Database database)
Copyright © 2012 Liquibase.org. All Rights Reserved.