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 class
SQLRunnerProxy.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 void
commitCurrentTransaction()
Commits current transactionDatabaseType
getDatabaseType()
Returns the type of database this data source connected to.SQLDialect
getDialect()
Provides with SQL functions.long
getNextId(String tableName, String idColumnName)
org.springframework.transaction.support.TransactionTemplate
getTransactionTemplate()
Provides with a ready to use Spring's transaction template.<T> T
runAndRetry(DBAction<T> action)
Runs the given function in its own transaction.void
runAndRetry(DBActionNoResults action)
Runs the given procedure in its own transaction.void
runDdl(String query, String task)
void
runDdls(String[] queries)
void
runDmls(String[] queries)
void
runSql(SQLRunner.NoResultSQLAction r)
void
runSql(SQLRunner.NoResultSQLAction r, boolean ignoreError)
<T> T
runSql(SQLRunner.SQLAction<T> r)
<T> T
withDB(DBAction<T> action)
Performs the specified function with a database.void
withDB(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:SQLRunnerEx
Returns 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:
getDatabaseType
in interfaceSQLRunnerEx
- Returns:
- the database type.
-
getTransactionTemplate
public org.springframework.transaction.support.TransactionTemplate getTransactionTemplate()
Description copied from interface:SQLRunnerEx
Provides 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:
getTransactionTemplate
in 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:DBFunctionsProvider
Performs the specified procedure with a database.- Specified by:
withDB
in 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:DBFunctionsProvider
Performs the specified function with a database. TheDBFunctionsProvider.getWithDB(DBAction)
is preferred because allows to avoid redundant actions casting to theDBAction
.- Specified by:
withDB
in 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:DBFunctionsProvider
Runs the given procedure in its own transaction.If this procedure became a deadlock victim or when
RetryException
occurred, 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:
runAndRetry
in 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:DBFunctionsProvider
Runs the given function in its own transaction.If this function became a deadlock victim or when
RetryException
occurred, 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:
runAndRetry
in 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:DBFunctionsProvider
Provides with SQL functions.- Specified by:
getDialect
in interfaceDBFunctionsProvider
- Returns:
- an instance of
SQLDialect
object, probably a shared instance.
-
runDdl
public void runDdl(@NotNull String query, @NotNull String task) throws org.springframework.jdbc.UncategorizedSQLException
- Specified by:
runDdl
in interfaceSQLRunnerEx
- Throws:
org.springframework.jdbc.UncategorizedSQLException
-
runDdls
public void runDdls(@NotNull String[] queries) throws org.springframework.jdbc.UncategorizedSQLException
- Specified by:
runDdls
in interfaceSQLRunnerEx
- Throws:
org.springframework.jdbc.UncategorizedSQLException
-
runDmls
public void runDmls(@NotNull String[] queries) throws org.springframework.jdbc.UncategorizedSQLException
- Specified by:
runDmls
in interfaceSQLRunnerEx
- Throws:
org.springframework.jdbc.UncategorizedSQLException
-
runSql
public <T> T runSql(@NotNull SQLRunner.SQLAction<T> r)
- Specified by:
runSql
in interfaceSQLRunner
- Specified by:
runSql
in interfaceSQLRunnerEx
-
commitCurrentTransaction
public void commitCurrentTransaction()
Description copied from interface:SQLRunner
Commits current transaction- Specified by:
commitCurrentTransaction
in interfaceSQLRunner
-
-