Package liquibase.executor
Class LoggingExecutor
java.lang.Object
liquibase.executor.AbstractExecutor
liquibase.executor.LoggingExecutor
- Direct Known Subclasses:
MockExecutor
A variant of the Executor service that does not actually modify the target database(s). Instead, it creates
the SQL statements that would be executed. This is intended for cautious DBAs who want to examine and verify
the generated changes.
-
Field Summary
Fields inherited from class liquibase.executor.AbstractExecutor
database, resourceAccessorFields inherited from interface liquibase.plugin.Plugin
PRIORITY_DATABASE, PRIORITY_DEFAULT, PRIORITY_NOT_APPLICABLE, PRIORITY_SPECIALIZED -
Constructor Summary
ConstructorsConstructorDescriptionLoggingExecutor(Executor delegatedExecutor, Writer output, Database database) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a comment to the database.voidexecute(SqlStatement sql) voidexecute(SqlStatement sql, List<SqlVisitor> sqlVisitors) getName()Return the name of the Executorprotected WriterintReturn the Executor priorityintqueryForInt(SqlStatement sql) Executes a query that is expected to return a scalar (1 row, 1 column).intqueryForInt(SqlStatement sql, List<SqlVisitor> sqlVisitors) Applies a number of SqlVisitors to the sql query.queryForList(SqlStatement sql) Executes a given SQL statement and returns a List of rows.queryForList(SqlStatement sql, Class elementType) queryForList(SqlStatement sql, Class elementType, List<SqlVisitor> sqlVisitors) queryForList(SqlStatement sql, List<SqlVisitor> sqlVisitors) Applies a list of SqlVisitors to the SQL query, then executes the (possibly modified) SQL query and lastly, returns the list of rows.longqueryForLong(SqlStatement sql) Executes a query that is expected to return a scalar (1 row, 1 column).longqueryForLong(SqlStatement sql, List<SqlVisitor> sqlVisitors) Applies a number of SqlVisitors to the sql query.<T> TqueryForObject(SqlStatement sql, Class<T> requiredType) Execute a query that is expected to return a scalar (1 row, 1 column).<T> TqueryForObject(SqlStatement sql, Class<T> requiredType, List<SqlVisitor> sqlVisitors) Applies a number of SqlVisitors to the sql query.intupdate(SqlStatement sql) intupdate(SqlStatement sql, List<SqlVisitor> sqlVisitors) booleanMethods inherited from class liquibase.executor.AbstractExecutor
applyVisitors, execute, execute, modifyChangeSet, setDatabase, setResourceAccessor, validate
-
Constructor Details
-
LoggingExecutor
-
-
Method Details
-
getName
Return the name of the Executor- Specified by:
getNamein interfaceExecutor- Specified by:
getNamein classAbstractExecutor- Returns:
- String The Executor name
-
getPriority
public int getPriority()Return the Executor priority- Specified by:
getPriorityin interfaceExecutor- Specified by:
getPriorityin classAbstractExecutor- Returns:
- int The Executor priority
-
getOutput
-
execute
- Throws:
DatabaseException
-
update
- Throws:
DatabaseException
-
execute
- Throws:
DatabaseException
-
update
- Throws:
DatabaseException
-
comment
Description copied from interface:ExecutorAdds a comment to the database. Currently does nothing but is overridden in the output JDBC template- Throws:
DatabaseException
-
queryForObject
Description copied from interface:ExecutorExecute a query that is expected to return a scalar (1 row, 1 column). It is expected that the scalar can be cast into an object of type T.- Parameters:
sql- The query to execute- Returns:
- An object of type T, if successful. May also return null if no object is found.
- Throws:
DatabaseException- in case something goes wrong during the query execution
-
queryForObject
public <T> T queryForObject(SqlStatement sql, Class<T> requiredType, List<SqlVisitor> sqlVisitors) throws DatabaseException Description copied from interface:ExecutorApplies a number of SqlVisitors to the sql query. Then, executes the (possibly modified) query. The query is expected to return a scalar (1 row, 1 column). That scalar is expected to return a single value that can be cast into an object of type T.- Parameters:
sql- The query to execute- Returns:
- An object of type T, if successful. May also return null if no object is found.
- Throws:
DatabaseException- in case something goes wrong during the query execution
-
queryForLong
Description copied from interface:ExecutorExecutes a query that is expected to return a scalar (1 row, 1 column). It is expected that the scalar can be cast into a long.- Parameters:
sql- The query to execute- Returns:
- A long value, if successful
- Throws:
DatabaseException- in case something goes wrong during the query execution
-
queryForLong
Description copied from interface:ExecutorApplies a number of SqlVisitors to the sql query. Then, executes the (possibly modified) query. The query is expected to return a scalar (1 row, 1 column), and that scalar is expected to be a long value.- Parameters:
sql- The query to execute- Returns:
- A long value, if successful
- Throws:
DatabaseException- in case something goes wrong during the query execution
-
queryForInt
Description copied from interface:ExecutorExecutes a query that is expected to return a scalar (1 row, 1 column). It is expected that the scalar can be cast into an int.- Parameters:
sql- The query to execute- Returns:
- An integer, if successful
- Throws:
DatabaseException- in case something goes wrong during the query execution
-
queryForInt
Description copied from interface:ExecutorApplies a number of SqlVisitors to the sql query. Then, executes the (possibly modified) query. The query is expected to return a scalar (1 row, 1 column), and that scalar is expected to be an int.- Parameters:
sql- The query to execute- Returns:
- An integer, if successful
- Throws:
DatabaseException- in case something goes wrong during the query execution
-
queryForList
- Throws:
DatabaseException
-
queryForList
public List queryForList(SqlStatement sql, Class elementType, List<SqlVisitor> sqlVisitors) throws DatabaseException - Throws:
DatabaseException
-
queryForList
Description copied from interface:ExecutorExecutes a given SQL statement and returns a List of rows. Each row is represented a a Map<String, ?>, where the String is the column name and the value if the content of the column in the row (=cell).- Parameters:
sql- the SQL query to execute- Returns:
- a List of [Column name] -> [column value]-mapped rows.
- Throws:
DatabaseException- if an error occurs during SQL processing (e.g. the SQL is not valid for the database)
-
queryForList
public List<Map<String,?>> queryForList(SqlStatement sql, List<SqlVisitor> sqlVisitors) throws DatabaseException Description copied from interface:ExecutorApplies a list of SqlVisitors to the SQL query, then executes the (possibly modified) SQL query and lastly, returns the list of rows. Each row is represented a a Map<String, ?>, where the String is the column name and the value if the content of the column in the row (=cell).- Parameters:
sql- the SQL query to execute- Returns:
- a List of [Column name] -> [column value]-mapped rows.
- Throws:
DatabaseException- if an error occurs during SQL processing (e.g. the SQL is not valid for the database)
-
updatesDatabase
public boolean updatesDatabase()
-