Top Description Inners Fields Constructors Methods
liquibase.executor

public Class LoggingExecutor

extends AbstractExecutor
Class Inheritance
Known Direct Subclasses
liquibase.sdk.executor.MockExecutor
Annotations
@LiquibaseService
skip:true
Imports
liquibase.database.Database, liquibase.database.core.MSSQLDatabase, .OracleDatabase, .SybaseASADatabase, .SybaseDatabase, liquibase.exception.DatabaseException, liquibase.servicelocator.LiquibaseService, .PrioritizedService, liquibase.sql.visitor.SqlVisitor, liquibase.sqlgenerator.SqlGeneratorFactory, liquibase.statement.ExecutablePreparedStatement, .SqlStatement, liquibase.statement.core.*, liquibase.util.StreamUtil, java.io.IOException, .Writer, java.util.ArrayList, .List, .Map

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.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private final Executor
private final Writer
Inherited from liquibase.executor.AbstractExecutor:
databaseresourceAccessor

Constructor Summary

AccessConstructor and Description
public
LoggingExecutor(Executor delegatedExecutor, Writer output, Database database)

Method Summary

Modifier and TypeMethod and Description
public void
comment(String message)

Implements liquibase.executor.Executor.comment.

Adds a comment to the database.

public void
public void
public String

Returns:

String The Executor name
getName
()

Implements abstract liquibase.executor.AbstractExecutor.getName.

Implements liquibase.executor.Executor.getName.

Return the name of the Executor

protected Writer
public int

Returns:

int The Executor priority
getPriority
()

Implements abstract liquibase.executor.AbstractExecutor.getPriority.

Implements liquibase.executor.Executor.getPriority.

Return the Executor priority

private void
private void
public int
queryForInt(SqlStatement
The query to execute
sql
)

Implements liquibase.executor.Executor.queryForInt.

Executes a query that is expected to return a scalar (1 row, 1 column).

public int
queryForInt(SqlStatement
The query to execute
sql
,
List<SqlVisitor> sqlVisitors)

Implements liquibase.executor.Executor.queryForInt.

Applies a number of SqlVisitors to the sql query.

public List<E>
public List<E>
public List<Map<String, ?>>
queryForList(SqlStatement
the SQL query to execute
sql
)

Implements liquibase.executor.Executor.queryForList.

Executes a given SQL statement and returns a List of rows.

public List<Map<String, ?>>
queryForList(SqlStatement
the SQL query to execute
sql
,
List<SqlVisitor> sqlVisitors)

Implements liquibase.executor.Executor.queryForList.

Applies a list of SqlVisitors to the SQL query, then executes the (possibly modified) SQL query and lastly, returns the list of rows.

public long
queryForLong(SqlStatement
The query to execute
sql
)

Implements liquibase.executor.Executor.queryForLong.

Executes a query that is expected to return a scalar (1 row, 1 column).

public long
queryForLong(SqlStatement
The query to execute
sql
,
List<SqlVisitor> sqlVisitors)

Implements liquibase.executor.Executor.queryForLong.

Applies a number of SqlVisitors to the sql query.

public <T> T
queryForObject(SqlStatement
The query to execute
sql
,
Class<T> requiredType)

Implements liquibase.executor.Executor.queryForObject.

Execute a query that is expected to return a scalar (1 row, 1 column).

public <T> T
queryForObject(SqlStatement
The query to execute
sql
,
Class<T> requiredType, List<SqlVisitor> sqlVisitors)

Implements liquibase.executor.Executor.queryForObject.

Applies a number of SqlVisitors to the sql query.

public int
public int
public boolean
Inherited from liquibase.executor.AbstractExecutor:
applyVisitorsexecuteexecutemodifyChangeSetsetDatabasesetResourceAccessorvalidate

Field Detail

delegatedReadExecutorback to summary
private final Executor delegatedReadExecutor
outputback to summary
private final Writer output

Constructor Detail

LoggingExecutorback to summary
public LoggingExecutor(Executor delegatedExecutor, Writer output, Database database)

Method Detail

commentback to summary
public void comment(String message) throws DatabaseException

Implements liquibase.executor.Executor.comment.

Doc from liquibase.executor.Executor.comment.

Adds a comment to the database. Currently does nothing but is overridden in the output JDBC template

Annotations
@Override
executeback to summary
public void execute(SqlStatement sql) throws DatabaseException

Implements liquibase.executor.Executor.execute.

Annotations
@Override
executeback to summary
public void execute(SqlStatement sql, List<SqlVisitor> sqlVisitors) throws DatabaseException

Implements liquibase.executor.Executor.execute.

Annotations
@Override
getNameback to summary
public String getName()

Implements abstract liquibase.executor.AbstractExecutor.getName.

Implements liquibase.executor.Executor.getName.

Return the name of the Executor

Returns:String

String The Executor name

Annotations
@Override
getOutputback to summary
protected Writer getOutput()
getPriorityback to summary
public int getPriority()

Implements abstract liquibase.executor.AbstractExecutor.getPriority.

Implements liquibase.executor.Executor.getPriority.

Return the Executor priority

Returns:int

int The Executor priority

Annotations
@Override
outputStatementback to summary
private void outputStatement(SqlStatement sql) throws DatabaseException
outputStatementback to summary
private void outputStatement(SqlStatement sql, List<SqlVisitor> sqlVisitors) throws DatabaseException
queryForIntback to summary
public int queryForInt(SqlStatement sql) throws DatabaseException

Implements liquibase.executor.Executor.queryForInt.

Doc from liquibase.executor.Executor.queryForInt.

Executes 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:SqlStatement

The query to execute

Returns:int

An integer, if successful

Annotations
@Override
Exceptions
DatabaseException:
in case something goes wrong during the query execution
queryForIntback to summary
public int queryForInt(SqlStatement sql, List<SqlVisitor> sqlVisitors) throws DatabaseException

Implements liquibase.executor.Executor.queryForInt.

Doc from liquibase.executor.Executor.queryForInt.

Applies 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:SqlStatement

The query to execute

Returns:int

An integer, if successful

Annotations
@Override
Exceptions
DatabaseException:
in case something goes wrong during the query execution
queryForListback to summary
public List<E> queryForList(SqlStatement sql, Class<T> elementType) throws DatabaseException

Implements liquibase.executor.Executor.queryForList.

Annotations
@Override
queryForListback to summary
public List<E> queryForList(SqlStatement sql, Class<T> elementType, List<SqlVisitor> sqlVisitors) throws DatabaseException

Implements liquibase.executor.Executor.queryForList.

Annotations
@Override
queryForListback to summary
public List<Map<String, ?>> queryForList(SqlStatement sql) throws DatabaseException

Implements liquibase.executor.Executor.queryForList.

Doc from liquibase.executor.Executor.queryForList.

Executes a given SQL statement and returns a List of rows. Each row is represented a a Map, where the String is the column name and the value if the content of the column in the row (=cell).

Parameters
sql:SqlStatement

the SQL query to execute

Returns:List<Map<String, ?>>

a List of [Column name] -> [column value]-mapped rows.

Annotations
@Override
Exceptions
DatabaseException:
if an error occurs during SQL processing (e.g. the SQL is not valid for the database)
queryForListback to summary
public List<Map<String, ?>> queryForList(SqlStatement sql, List<SqlVisitor> sqlVisitors) throws DatabaseException

Implements liquibase.executor.Executor.queryForList.

Doc from liquibase.executor.Executor.queryForList.

Applies 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, where the String is the column name and the value if the content of the column in the row (=cell).

Parameters
sql:SqlStatement

the SQL query to execute

Returns:List<Map<String, ?>>

a List of [Column name] -> [column value]-mapped rows.

Annotations
@Override
Exceptions
DatabaseException:
if an error occurs during SQL processing (e.g. the SQL is not valid for the database)
queryForLongback to summary
public long queryForLong(SqlStatement sql) throws DatabaseException

Implements liquibase.executor.Executor.queryForLong.

Doc from liquibase.executor.Executor.queryForLong.

Executes 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:SqlStatement

The query to execute

Returns:long

A long value, if successful

Annotations
@Override
Exceptions
DatabaseException:
in case something goes wrong during the query execution
queryForLongback to summary
public long queryForLong(SqlStatement sql, List<SqlVisitor> sqlVisitors) throws DatabaseException

Implements liquibase.executor.Executor.queryForLong.

Doc from liquibase.executor.Executor.queryForLong.

Applies 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:SqlStatement

The query to execute

Returns:long

A long value, if successful

Annotations
@Override
Exceptions
DatabaseException:
in case something goes wrong during the query execution
queryForObjectback to summary
public <T> T queryForObject(SqlStatement sql, Class<T> requiredType) throws DatabaseException

Implements liquibase.executor.Executor.queryForObject.

Doc from liquibase.executor.Executor.queryForObject.

Execute 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:SqlStatement

The query to execute

Returns:T

An object of type T, if successful. May also return null if no object is found.

Annotations
@Override
Exceptions
DatabaseException:
in case something goes wrong during the query execution
queryForObjectback to summary
public <T> T queryForObject(SqlStatement sql, Class<T> requiredType, List<SqlVisitor> sqlVisitors) throws DatabaseException

Implements liquibase.executor.Executor.queryForObject.

Doc from liquibase.executor.Executor.queryForObject.

Applies 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:SqlStatement

The query to execute

Returns:T

An object of type T, if successful. May also return null if no object is found.

Annotations
@Override
Exceptions
DatabaseException:
in case something goes wrong during the query execution
updateback to summary
public int update(SqlStatement sql) throws DatabaseException

Implements liquibase.executor.Executor.update.

Annotations
@Override
updateback to summary
public int update(SqlStatement sql, List<SqlVisitor> sqlVisitors) throws DatabaseException

Implements liquibase.executor.Executor.update.

Annotations
@Override
updatesDatabaseback to summary
public boolean updatesDatabase()

Implements liquibase.executor.Executor.updatesDatabase.

Annotations
@Override
liquibase.executor back to summary

private Class LoggingExecutor.NoopWriter

extends Writer
Class Inheritance

Field Summary

Inherited from java.io.Writer:
lock

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements abstract java.io.Writer.close.

Implements java.io.Closeable.close.

Closes the stream, flushing it first.

public void
flush()

Implements abstract java.io.Writer.flush.

Implements java.io.Flushable.flush.

Flushes the stream.

public void
write(char[]
Array of characters
cbuf
,
int
Offset from which to start writing characters
off
,
int
Number of characters to write
len
)

Implements abstract java.io.Writer.write.

Writes a portion of an array of characters.

Inherited from java.io.Writer:
appendappendappendnullWriterwritewritewritewrite

Constructor Detail

NoopWriterback to summary
private NoopWriter()

Method Detail

closeback to summary
public void close() throws IOException

Implements abstract java.io.Writer.close.

Implements java.io.Closeable.close.

Doc from java.io.Writer.close.

Closes the stream, flushing it first. Once the stream has been closed, further write() or flush() invocations will cause an IOException to be thrown. Closing a previously closed stream has no effect.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
flushback to summary
public void flush() throws IOException

Implements abstract java.io.Writer.flush.

Implements java.io.Flushable.flush.

Doc from java.io.Writer.flush.

Flushes the stream. If the stream has saved any characters from the various write() methods in a buffer, write them immediately to their intended destination. Then, if that destination is another character or byte stream, flush it. Thus one flush() invocation will flush all the buffers in a chain of Writers and OutputStreams.

If the intended destination of this stream is an abstraction provided by the underlying operating system, for example a file, then flushing the stream guarantees only that bytes previously written to the stream are passed to the operating system for writing; it does not guarantee that they are actually written to a physical device such as a disk drive.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
writeback to summary
public void write(char[] cbuf, int off, int len) throws IOException

Implements abstract java.io.Writer.write.

Doc from java.io.Writer.write.

Writes a portion of an array of characters.

Parameters
cbuf:char[]

Array of characters

off:int

Offset from which to start writing characters

len:int

Number of characters to write

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs