Interface DBFunctionsProvider
-
- All Known Subinterfaces:
SQLRunnerEx
- All Known Implementing Classes:
DBFacade
,SQLRunnerProxy
,TeamCityDatabaseManager
public interface DBFunctionsProvider
A simple interface that defines withDB methods.The main methods of this interface are
withDB(jetbrains.buildServer.serverSide.db.DBAction<T>)
. They executes the specified method providing a database access.As of transaction handling, ask the documentation of concrete implementation.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description SQLDialect
getDialect()
Provides with SQL functions.default <T> T
getWithDB(DBAction<T> action)
Performs the specified function with a database.<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.<T> T
withDB(DBAction<T> action)
Performs the specified function with a database.void
withDB(DBActionNoResults action)
Performs the specified procedure with a database.
-
-
-
Method Detail
-
getWithDB
default <T> T getWithDB(@NotNull DBAction<T> action)
Performs the specified function with a database.- 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)
. - Since:
- 2022.1
- See Also:
withDB(DBActionNoResults)
,runAndRetry(DBAction)
-
withDB
<T> T withDB(@NotNull DBAction<T> action)
Performs the specified function with a database. ThegetWithDB(DBAction)
is preferred because allows to avoid redundant actions casting to theDBAction
.- 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:
withDB(DBActionNoResults)
,runAndRetry(DBAction)
-
withDB
void withDB(@NotNull DBActionNoResults action)
Performs the specified procedure with a database.- Parameters:
action
- action (class that implements procedureDBActionNoResults.run(jetbrains.buildServer.serverSide.db.DBFunctions)
) to perform.- See Also:
withDB(DBAction)
,runAndRetry(DBActionNoResults)
-
runAndRetry
<T> T runAndRetry(@NotNull DBAction<T> action)
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.
- 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:
runAndRetry(DBActionNoResults)
,withDB(DBAction)
,RetryException
-
runAndRetry
void runAndRetry(@NotNull DBActionNoResults action)
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.
- Parameters:
action
- action (class that implements procedureDBActionNoResults.run(jetbrains.buildServer.serverSide.db.DBFunctions)
) to perform.- See Also:
runAndRetry(DBAction)
,withDB(DBActionNoResults)
,RetryException
-
getDialect
@NotNull SQLDialect getDialect()
Provides with SQL functions.- Returns:
- an instance of
SQLDialect
object, probably a shared instance.
-
-