Top Description Methods
org.hibernate.annotations

public @Interface OptimisticLocking

extends Annotation
Annotations
@Target:TYPE
@Retention:RUNTIME
Imports
java.lang.annotation.Retention, .Target

Specifies how optimistic lock checking works for the annotated entity.

Optimistic lock checking may detect that an optimistic lock has failed, and that the transaction should be aborted, by comparing either:

An optimistic lock is usually checked by including a restriction in a SQL update or delete statement. If the database reports that zero rows were updated, it is inferred that another transaction has already updated or deleted the row, and the failure of the optimistic lock is reported via an jakarta.persistence.OptimisticLockException.

In an inheritance hierarchy, this annotation may only be applied to the root entity, since the optimistic lock checking strategy is inherited by entity subclasses.

To exclude a particular attribute from optimistic locking, annotate the attribute @OptimisticLock(excluded=true). Then:

Author
Steve Ebersole
See Also
org.hibernate.LockMode, jakarta.persistence.LockModeType

Method Summary

Modifier and TypeMethod and Description
public OptimisticLockType
type()

The optimistic lock checking strategy.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

typeback to summary
public OptimisticLockType type()

The optimistic lock checking strategy.