use of liquibase.statement.core.TableRowCountStatement in project liquibase by liquibase.
the class RowCountPrecondition method check.
@Override
public void check(Database database, DatabaseChangeLog changeLog, ChangeSet changeSet) throws PreconditionFailedException, PreconditionErrorException {
try {
TableRowCountStatement statement = new TableRowCountStatement(catalogName, schemaName, tableName);
int result = ExecutorService.getInstance().getExecutor(database).queryForInt(statement);
if (result != expectedRows) {
throw new PreconditionFailedException(getFailureMessage(result), changeLog, this);
}
} catch (PreconditionFailedException e) {
throw e;
} catch (Exception e) {
throw new PreconditionErrorException(e, changeLog, this);
}
}
use of liquibase.statement.core.TableRowCountStatement in project liquibase by liquibase.
the class RowCountPrecondition method check.
@Override
public void check(Database database, DatabaseChangeLog changeLog, ChangeSet changeSet, ChangeExecListener changeExecListener) throws PreconditionFailedException, PreconditionErrorException {
try {
TableRowCountStatement statement = new TableRowCountStatement(catalogName, schemaName, tableName);
int result = Scope.getCurrentScope().getSingleton(ExecutorService.class).getExecutor("jdbc", database).queryForInt(statement);
if (result != expectedRows) {
throw new PreconditionFailedException(getFailureMessage(result), changeLog, this);
}
} catch (PreconditionFailedException e) {
throw e;
} catch (Exception e) {
throw new PreconditionErrorException(e, changeLog, this);
}
}
Aggregations