Package liquibase.snapshot.jvm
Class JdbcSnapshotGenerator
java.lang.Object
liquibase.snapshot.jvm.JdbcSnapshotGenerator
- All Implemented Interfaces:
SnapshotGenerator
- Direct Known Subclasses:
CatalogSnapshotGenerator,ColumnSnapshotGenerator,DataSnapshotGenerator,ForeignKeySnapshotGenerator,IndexSnapshotGenerator,PrimaryKeySnapshotGenerator,SchemaSnapshotGenerator,SequenceSnapshotGenerator,TableSnapshotGenerator,UniqueConstraintSnapshotGenerator,ViewSnapshotGenerator
-
Field Summary
Fields inherited from interface liquibase.snapshot.SnapshotGenerator
PRIORITY_ADDITIONAL, PRIORITY_DATABASE, PRIORITY_DEFAULT, PRIORITY_NONE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedJdbcSnapshotGenerator(Class<? extends DatabaseObject> defaultFor) protectedJdbcSnapshotGenerator(Class<? extends DatabaseObject> defaultFor, Class<? extends DatabaseObject>[] addsTo) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddStatusListener(DiffStatusListener listener) Class<? extends DatabaseObject>[]addsTo()When snapshotting a certain object type (e.g. a table), different types of objects might be discovered in the process.protected abstract voidaddTo(DatabaseObject foundObject, DatabaseSnapshot snapshot) protected StringcleanNameFromDatabase(String objectName, Database database) protected String[]getDatabaseCatalogNames(Database database) Fetches an array of Strings with the catalog names in the database.intgetPriority(Class<? extends DatabaseObject> objectType, Database database) Inquire if this SnapshotGenerator is capable of snapshotting objects of type objectType (e.g.Class<? extends SnapshotGenerator>[]replaces()Returns classes (and superclasses) that this SnapshotGenerator replaces.protected booleanshouldAddTo(Class<? extends DatabaseObject> databaseObjectType, DatabaseSnapshot snapshot) snapshot(DatabaseObject example, DatabaseSnapshot snapshot, SnapshotGeneratorChain chain) Commands the SnapshotGenerator to create a snapshot (a representation of a database object in Java object form) of a specific database object.protected abstract DatabaseObjectsnapshotObject(DatabaseObject example, DatabaseSnapshot snapshot) protected voidupdateListeners(String message)
-
Constructor Details
-
JdbcSnapshotGenerator
-
JdbcSnapshotGenerator
protected JdbcSnapshotGenerator(Class<? extends DatabaseObject> defaultFor, Class<? extends DatabaseObject>[] addsTo)
-
-
Method Details
-
getPriority
Description copied from interface:SnapshotGeneratorInquire if this SnapshotGenerator is capable of snapshotting objects of type objectType (e.g. Table, Index, View etc.) in the DBMS database (e.g. Oracle, Postgres, HyperSQL etc.) A return priority of > 0 will be interpreted as capable. The highest priority for an objectType-database combination wins.- Specified by:
getPriorityin interfaceSnapshotGenerator- Parameters:
objectType- The object type we are asked to snapshotdatabase- The DBMS for which the snapshotting should be done- Returns:
- An integer of PRIORITY_... constants indicating our capability and willingness to snapshot
-
addsTo
Description copied from interface:SnapshotGeneratorWhen snapshotting a certain object type (e.g. a table), different types of objects might be discovered in the process. (TODO: Which ones? Needs a more precise description.)- Specified by:
addsToin interfaceSnapshotGenerator- Returns:
- an array of classes that this SnapshotGenerator might return upon snapshotting a given DatabaseObject type.
-
snapshot
public DatabaseObject snapshot(DatabaseObject example, DatabaseSnapshot snapshot, SnapshotGeneratorChain chain) throws DatabaseException, InvalidExampleException Description copied from interface:SnapshotGeneratorCommands the SnapshotGenerator to create a snapshot (a representation of a database object in Java object form) of a specific database object.- Specified by:
snapshotin interfaceSnapshotGenerator- Parameters:
example- The object we should try to snapshotsnapshot- The Snapshot object representing the result of the snapshot operations so farchain- A list of other SnapshotGenerators that might be asked to try the same- Returns:
- An object of type T if our snapshot attempt is successful
- Throws:
DatabaseException- If an operation on the database failsInvalidExampleException- If, for some reason, we cannot work on the example object (ambiguous naming etc.)
-
shouldAddTo
protected boolean shouldAddTo(Class<? extends DatabaseObject> databaseObjectType, DatabaseSnapshot snapshot) -
replaces
Description copied from interface:SnapshotGeneratorReturns classes (and superclasses) that this SnapshotGenerator replaces. Return null or empty array to not affect the SnapshotGeneratorChain.- Specified by:
replacesin interfaceSnapshotGenerator
-
snapshotObject
protected abstract DatabaseObject snapshotObject(DatabaseObject example, DatabaseSnapshot snapshot) throws DatabaseException, InvalidExampleException -
addTo
protected abstract void addTo(DatabaseObject foundObject, DatabaseSnapshot snapshot) throws DatabaseException, InvalidExampleException -
addStatusListener
-
updateListeners
-
cleanNameFromDatabase
-
getDatabaseCatalogNames
protected String[] getDatabaseCatalogNames(Database database) throws SQLException, DatabaseException Fetches an array of Strings with the catalog names in the database.- Parameters:
database- The database from which to get the schema names- Returns:
- An array of catalog name Strings (May be an empty array)
- Throws:
SQLException- propagated java.sql.SQLExceptionDatabaseException- if a different problem occurs during the DBMS-specific code
-