validate
Throws OptimisticLockingFailureException when expectedVersion is non-null and does not match currentVersion. A null expectedVersion is treated as "no check requested" and silently passes.
fun validate(currentVersion: Long?, expectedVersion: Long?, exceptionSupplier: () -> Throwable)(source)
Same contract as validate but throws a caller-supplied exception (built lazily by exceptionSupplier), letting domain modules surface a domain-specific error type instead of the generic Spring one.