Interface LockingSupport
Cohesive Dialect profile for pessimistic-locking capabilities and operations.
A provider supplies one profile from
Dialect.getLockingSupport() or a supported
family-specific supply point such as
AbstractSybaseDialect.getLockingSupport(). Its
metadata and strategies must describe the same behavior: for example, a
TABLE_HINT style must provide a table-hint renderer, and an
already-rendered SQL rewriter must return UNSUPPORTED when the available
structure cannot place those hints safely.
Hibernate may retain and reuse the profile and its returned components for
the lifetime of the Dialect. Implementations should therefore be immutable
or thread-safe and must not retain request-specific state. Per-translation
target collection belongs to LockingClauseStrategy, not this profile.
- Since:
- 8.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceImmutable description of the locking syntax and timeout capabilities of a Dialect. -
Method Summary
Modifier and TypeMethodDescriptionThe strategy for applying lock timeouts through the JDBC connection, generally by executing a database command.default FollowOnLockingPolicyThe policy for deciding whether completed SQL requires follow-on locking.The renderer for a complete statement-level locking clause.default LockingSqlRewriterThe strategy for applying locking to already-rendered native or legacy SQL.Immutable capability metadata consistent with this profile's renderers and strategies.default TableLockHintRendererThe renderer for table-level locking hints.default TransactionConcurrencyResolverResolves environment-specific concurrency facts without retaining or modifying a connection.default StringrenderCurrentReadClause(TransactionConcurrency concurrency) Renders the clause, if any, which, appended to a simple single-tableselect, makes it a current read, as described forrenderCurrentReadTableHint(String, TransactionConcurrency).default StringrenderCurrentReadTableHint(String tableExpression, TransactionConcurrency concurrency) Renders the table hint, if any, which makes a simple single-tableselecta current read: a read which returns the latest committed state of the selected rows, waiting for the outcome of any concurrent uncommitted write to them, instead of returning state from a snapshot.
-
Method Details
-
getTransactionConcurrencyResolver
Resolves environment-specific concurrency facts without retaining or modifying a connection. The resolved descriptor belongs to JdbcEnvironment, not to this potentially shared dialect profile. -
renderCurrentReadTableHint
@SPI({USE,IMPLEMENT}) default String renderCurrentReadTableHint(String tableExpression, TransactionConcurrency concurrency) Renders the table hint, if any, which makes a simple single-table
selecta current read: a read which returns the latest committed state of the selected rows, waiting for the outcome of any concurrent uncommitted write to them, instead of returning state from a snapshot. A conflicting write may instead cause the read to fail. A successful current read does not itself guarantee that the state remains unchanged until transaction completion. Hibernate performs a current read for the version check it executes just before commit for an entity locked inLockMode.OPTIMISTICmode.The caller uses the resolved
TransactionConcurrencyto decide whether an ordinaryOperation.READalready providesReadGuarantees.isCurrentRead(). If so, the caller omits explicit current-read rendering. Otherwise, the caller must establish thatOperation.CURRENT_READis supported and provides that guarantee before invoking this method. This method renders the explicit strategy; it does not repeat that decision.By default, a
PessimisticLockStyle.TABLE_HINTprofile renders its share-lock hint, and other profiles render nothing. A profile may override this to render a cheaper form which waits for the outcome of concurrent writes but retains no lock.- Parameters:
tableExpression- The table reference the hint will followconcurrency- The resolved transaction concurrency descriptor- Returns:
- The table hint, or an empty string if this profile uses no table hint
- See Also:
-
renderCurrentReadClause
Renders the clause, if any, which, appended to a simple single-table
select, makes it a current read, as described forrenderCurrentReadTableHint(String, TransactionConcurrency).The caller consults the resolved
TransactionConcurrencyand omits explicit current-read rendering when an ordinaryOperation.READis already current. Otherwise, the caller must establish thatOperation.CURRENT_READis supported and providesReadGuarantees.isCurrentRead()before invoking this method.By default, a
PessimisticLockStyle.CLAUSEprofile renders its share-lock clause, and other profiles render nothing. A profile may override this to render a cheaper form which waits for the outcome of concurrent writes but retains no lock.- Parameters:
concurrency- The resolved transaction concurrency descriptor- Returns:
- The clause, or an empty string if this profile uses no locking clause
- See Also:
-
getLockingClauseRenderer
The renderer for a complete statement-level locking clause. ReturnLockingClauseRenderer.NO_OPwhen this profile does not use one.- Since:
- 8.0
- See Also:
-
getTableLockHintRenderer
The renderer for table-level locking hints. The default reports that this profile does not use table hints.- Since:
- 8.0
- See Also:
-
getLockingSqlRewriter
The strategy for applying locking to already-rendered native or legacy SQL. The default derives safe placement from this profile's locking style.- Since:
- 8.0
- See Also:
-
getFollowOnLockingPolicy
The policy for deciding whether completed SQL requires follow-on locking. The default never requests it.- Since:
- 8.0
- See Also:
-
getMetadata
Immutable capability metadata consistent with this profile's renderers and strategies.- See Also:
-
getConnectionLockTimeoutStrategy
The strategy for applying lock timeouts through the JDBC connection, generally by executing a database command. ReturnConnectionLockTimeoutStrategy.NONEwhen unsupported.- See Also:
-