Top Description Fields Methods
liquibase.executor

public Interface Executor

extends Plugin
Known Direct Implementers
liquibase.executor.AbstractExecutor
Imports
liquibase.change.Change, liquibase.changelog.ChangeSet, liquibase.database.Database, liquibase.exception.DatabaseException, .ValidationErrors, liquibase.plugin.Plugin, liquibase.resource.ResourceAccessor, liquibase.sql.visitor.SqlVisitor, liquibase.statement.SqlStatement, java.util.List, .Map

Interface for a class that is capable of executing statements/queries against a DBMS.

Field Summary

Inherited from liquibase.plugin.Plugin:
PRIORITY_DATABASEPRIORITY_DEFAULTPRIORITY_NOT_APPLICABLEPRIORITY_SPECIALIZED

Method Summary

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

Adds a comment to the database.

public void
execute(Change change)

Write methods

public void
execute(Change change, List<SqlVisitor> sqlVisitors)

public void
public void
execute(SqlStatement sql, List<SqlVisitor> sqlVisitors)

public String

Returns:

String The Executor name
getName
()

Return the name of the Executor

public int

Returns:

int The Executor priority
getPriority
()

Return the Executor priority

public void
modifyChangeSet(ChangeSet
The changeset to operate on
changeSet
)

Allow this Executor to make any needed changes to the changeset

public int

Returns:

An integer, if successful
queryForInt
(SqlStatement
The query to execute
sql
)

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

public int

Returns:

An integer, if successful
queryForInt
(SqlStatement
The query to execute
sql
,
List<SqlVisitor> sqlVisitors)

Applies a number of SqlVisitors to the sql query.

public List<E>
queryForList(SqlStatement sql, Class<T> elementType)

public List<E>
queryForList(SqlStatement sql, Class<T> elementType, List<SqlVisitor> sqlVisitors)

public List<Map<String, ?>>

Returns:

a List of [Column name] -> [column value]-mapped rows.
queryForList
(SqlStatement
the SQL query to execute
sql
)

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

public List<Map<String, ?>>

Returns:

a List of [Column name] -> [column value]-mapped rows.
queryForList
(SqlStatement
the SQL query to execute
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.

public long

Returns:

A long value, if successful
queryForLong
(SqlStatement
The query to execute
sql
)

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

public long

Returns:

A long value, if successful
queryForLong
(SqlStatement
The query to execute
sql
,
List<SqlVisitor> sqlVisitors)

Applies a number of SqlVisitors to the sql query.

public <T> T

Returns:

An object of type T, if successful. May also return null if no object is found.
queryForObject
(SqlStatement
The query to execute
sql
,
Class<T> requiredType)

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

public <T> T

Returns:

An object of type T, if successful. May also return null if no object is found.
queryForObject
(SqlStatement
The query to execute
sql
,
Class<T> requiredType, List<SqlVisitor> sqlVisitors)

Applies a number of SqlVisitors to the sql query.

public void
setDatabase(Database
The database
database
)

Configures the Executor for the Database to run statements/queries against.

public void
setResourceAccessor(ResourceAccessor resourceAccessor)

Set a ResourceAccessor on this Executor to be used in file access

public default boolean

Returns:

true if Database is supported by current Executor implementation.
supports
(final Database
the Database implementation opened from a url connection string
database
)

Default implementation for compatibility with a Database.

public int
public int
update(SqlStatement sql, List<SqlVisitor> sqlVisitors)

public boolean
public ValidationErrors

Returns:

ValidationErrors Any errors which occur during validation
validate
(ChangeSet
The changeset to validate
changeSet
)

Validate if the changeset can be executed by this Executor If the ChangeSet can be executed return an empty ValidationErrors object otherwise return the errors

Method Detail

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

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

executeback to summary
public void execute(Change change) throws DatabaseException

Write methods

executeback to summary
public void execute(Change change, List<SqlVisitor> sqlVisitors) throws DatabaseException
executeback to summary
public void execute(SqlStatement sql) throws DatabaseException
executeback to summary
public void execute(SqlStatement sql, List<SqlVisitor> sqlVisitors) throws DatabaseException
getNameback to summary
public String getName()

Return the name of the Executor

Returns:String

String The Executor name

getPriorityback to summary
public int getPriority()

Return the Executor priority

Returns:int

int The Executor priority

modifyChangeSetback to summary
public void modifyChangeSet(ChangeSet changeSet)

Allow this Executor to make any needed changes to the changeset

Parameters
changeSet:ChangeSet

The changeset to operate on

queryForIntback to summary
public int queryForInt(SqlStatement sql) throws DatabaseException

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

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

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

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
queryForListback to summary
public List<E> queryForList(SqlStatement sql, Class<T> elementType, List<SqlVisitor> sqlVisitors) throws DatabaseException
queryForListback to summary
public List<Map<String, ?>> queryForList(SqlStatement sql) throws DatabaseException

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.

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

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.

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

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

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

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

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

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.

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

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.

Exceptions
DatabaseException:
in case something goes wrong during the query execution
setDatabaseback to summary
public void setDatabase(Database database)

Configures the Executor for the Database to run statements/queries against.

Parameters
database:Database

The database

setResourceAccessorback to summary
public void setResourceAccessor(ResourceAccessor resourceAccessor)

Set a ResourceAccessor on this Executor to be used in file access

supportsback to summary
public default boolean supports(final Database database)

Default implementation for compatibility with a Database. Requires default implementation in order to provide backward compatibility. Method is used when ExecutorService is looking by a Executor implementation for a Database. Can be overridden in Executor implementations with a higher priority to check against a Database.

Parameters
database:Database

the Database implementation opened from a url connection string

Returns:boolean

true if Database is supported by current Executor implementation.

updateback to summary
public int update(SqlStatement sql) throws DatabaseException
updateback to summary
public int update(SqlStatement sql, List<SqlVisitor> sqlVisitors) throws DatabaseException
updatesDatabaseback to summary
public boolean updatesDatabase()
validateback to summary
public ValidationErrors validate(ChangeSet changeSet)

Validate if the changeset can be executed by this Executor If the ChangeSet can be executed return an empty ValidationErrors object otherwise return the errors

Parameters
changeSet:ChangeSet

The changeset to validate

Returns:ValidationErrors

ValidationErrors Any errors which occur during validation