Class SQLRunnerProxy
- java.lang.Object
-
- jetbrains.buildServer.serverSide.db.SQLRunnerProxy
-
- All Implemented Interfaces:
DBFunctionsProvider,SQLRunnerEx,SQLRunner
public class SQLRunnerProxy extends Object implements SQLRunnerEx
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSQLRunnerProxy.DeprecatedUsageException-
Nested classes/interfaces inherited from interface jetbrains.buildServer.serverSide.SQLRunner
SQLRunner.NoResultSQLAction, SQLRunner.SQLAction<T>
-
-
Constructor Summary
Constructors Constructor Description SQLRunnerProxy(SQLRunnerEx runner)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcommitCurrentTransaction()Commits current transactionDatabaseTypegetDatabaseType()Returns the type of database this data source connected to.SQLDialectgetDialect()Provides with SQL functions.longgetNextId(String tableName, String idColumnName)org.springframework.transaction.support.TransactionTemplategetTransactionTemplate()Provides with a ready to use Spring's transaction template.<T> TrunAndRetry(DBAction<T> action)Runs the given function in its own transaction.voidrunAndRetry(DBActionNoResults action)Runs the given procedure in its own transaction.voidrunDdl(String query, String task)voidrunDdls(String[] queries)voidrunDmls(String[] queries)voidrunSql(SQLRunner.NoResultSQLAction r)voidrunSql(SQLRunner.NoResultSQLAction r, boolean ignoreError)<T> TrunSql(SQLRunner.SQLAction<T> r)<T> TwithDB(DBAction<T> action)Performs the specified function with a database.voidwithDB(DBActionNoResults action)Performs the specified procedure with a database.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jetbrains.buildServer.serverSide.db.DBFunctionsProvider
getWithDB
-
-
-
-
Constructor Detail
-
SQLRunnerProxy
public SQLRunnerProxy(SQLRunnerEx runner)
-
-
Method Detail
-
getDatabaseType
public DatabaseType getDatabaseType()
Description copied from interface:SQLRunnerExReturns the type of database this data source connected to. This method is fast because it just returns the type value, doesn't perfrom any request and doesn't interact with database server ot jdbc driver.- Specified by:
getDatabaseTypein interfaceSQLRunnerEx- Returns:
- the database type.
-
getTransactionTemplate
public org.springframework.transaction.support.TransactionTemplate getTransactionTemplate()
Description copied from interface:SQLRunnerExProvides with a ready to use Spring's transaction template.This template may be invalidated on some database maintenance operations (such as cleanup, backup, etc.), so don't persist this reference in your classes.
- Specified by:
getTransactionTemplatein interfaceSQLRunnerEx- Returns:
- a Spring's transaction template.
-
runSql
public void runSql(@NotNull SQLRunner.NoResultSQLAction r)
-
runSql
public void runSql(@NotNull SQLRunner.NoResultSQLAction r, boolean ignoreError)
-
withDB
public void withDB(@NotNull DBActionNoResults action)Description copied from interface:DBFunctionsProviderPerforms the specified procedure with a database.- Specified by:
withDBin interfaceDBFunctionsProvider- Parameters:
action- action (class that implements procedureDBActionNoResults.run(jetbrains.buildServer.serverSide.db.DBFunctions)) to perform.- See Also:
DBFunctionsProvider.withDB(DBAction),DBFunctionsProvider.runAndRetry(DBActionNoResults)
-
withDB
public <T> T withDB(@NotNull DBAction<T> action)Description copied from interface:DBFunctionsProviderPerforms the specified function with a database. TheDBFunctionsProvider.getWithDB(DBAction)is preferred because allows to avoid redundant actions casting to theDBAction.- Specified by:
withDBin interfaceDBFunctionsProvider- Type Parameters:
T- type of returning value.- Parameters:
action- action (class that implement functionDBAction.run(jetbrains.buildServer.serverSide.db.DBFunctions)) to perform.- Returns:
- value returned by action.
DBAction.run(jetbrains.buildServer.serverSide.db.DBFunctions). - See Also:
DBFunctionsProvider.withDB(DBActionNoResults),DBFunctionsProvider.runAndRetry(DBAction)
-
runAndRetry
public void runAndRetry(@NotNull DBActionNoResults action)Description copied from interface:DBFunctionsProviderRuns the given procedure in its own transaction.If this procedure became a deadlock victim or when
RetryExceptionoccurred, it rolls the transaction back and re-runs the procedure (may be several times). Then, when success, commits the transaction.If an exception (not deadlock) occurred during the execution, the transaction will be rolled back the the occurred exception is thrown.
Warning! - there must be only database works with the given DBF instance inside the transaction. Using other database connections or performing file system operations inside this transaction can cause strange exceptions or even fall the system into stuck. Remember, that the commands inside can be performed several times.
- Specified by:
runAndRetryin interfaceDBFunctionsProvider- Parameters:
action- action (class that implements procedureDBActionNoResults.run(jetbrains.buildServer.serverSide.db.DBFunctions)) to perform.- See Also:
DBFunctionsProvider.runAndRetry(DBAction),DBFunctionsProvider.withDB(DBActionNoResults),RetryException
-
runAndRetry
public <T> T runAndRetry(@NotNull DBAction<T> action)Description copied from interface:DBFunctionsProviderRuns the given function in its own transaction.If this function became a deadlock victim or when
RetryExceptionoccurred, it rolls the transaction back and re-runs the function (may be several times). Then, when success, commits the transaction.If an exception (not deadlock) occurred during the execution, the transaction will be rolled back the the occurred exception is thrown.
Warning! - there must be only database works with the given DBF instance inside the transaction. Using other database connections or performing file system operations inside this transaction can cause strange exceptions or even fall the system into stuck. Remember, that the commands inside can be performed several times.
- Specified by:
runAndRetryin interfaceDBFunctionsProvider- Type Parameters:
T- type of returning value.- Parameters:
action- action (class that implement functionDBAction.run(jetbrains.buildServer.serverSide.db.DBFunctions)) to perform.- Returns:
- value returned by the function
DBAction.run(jetbrains.buildServer.serverSide.db.DBFunctions). - See Also:
DBFunctionsProvider.runAndRetry(DBActionNoResults),DBFunctionsProvider.withDB(DBAction),RetryException
-
getDialect
@NotNull public SQLDialect getDialect()
Description copied from interface:DBFunctionsProviderProvides with SQL functions.- Specified by:
getDialectin interfaceDBFunctionsProvider- Returns:
- an instance of
SQLDialectobject, probably a shared instance.
-
runDdl
public void runDdl(@NotNull String query, @NotNull String task) throws org.springframework.jdbc.UncategorizedSQLException- Specified by:
runDdlin interfaceSQLRunnerEx- Throws:
org.springframework.jdbc.UncategorizedSQLException
-
runDdls
public void runDdls(@NotNull String[] queries) throws org.springframework.jdbc.UncategorizedSQLException- Specified by:
runDdlsin interfaceSQLRunnerEx- Throws:
org.springframework.jdbc.UncategorizedSQLException
-
runDmls
public void runDmls(@NotNull String[] queries) throws org.springframework.jdbc.UncategorizedSQLException- Specified by:
runDmlsin interfaceSQLRunnerEx- Throws:
org.springframework.jdbc.UncategorizedSQLException
-
runSql
public <T> T runSql(@NotNull SQLRunner.SQLAction<T> r)- Specified by:
runSqlin interfaceSQLRunner- Specified by:
runSqlin interfaceSQLRunnerEx
-
commitCurrentTransaction
public void commitCurrentTransaction()
Description copied from interface:SQLRunnerCommits current transaction- Specified by:
commitCurrentTransactionin interfaceSQLRunner
-
-