-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathOptimisticLockException.java
47 lines (41 loc) · 1.69 KB
/
OptimisticLockException.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
* Made with all the love in the world
* by scireum in Remshalden, Germany
*
* Copyright by scireum GmbH
* http://www.scireum.de - [email protected]
*/
package sirius.db.mixing;
import java.io.Serial;
/**
* Signals that a concurrent modification occurred on a versioned entity which supports <tt>optimistic locking</tt>.
* <p>
* In contrast to <tt>pessimistic locking</tt>, <tt>optimistic locking</tt> does not acquire any locks or perform
* other measures to guarantee mutual exclusion. Rather it keeps track of the entity version it last read from
* the database and upon a modification, it expects the entity version in the database to remain the same.
* <p>
* Once a modification is performed, the version is then incremented. If the expected version does not match
* the actual version, the operation is aborted and an {@link OptimisticLockException} is thrown.
* <p>
* This yields a highly performant and highly scalable system as long as concurrent modifications are rare. The
* downside of this approach is, that modifications have to be retried once an error is detected. However, most of the
* time this overhead is quite bearable.
*/
public class OptimisticLockException extends Exception {
@Serial
private static final long serialVersionUID = -834083199170415643L;
/**
* Creates a new instance without any reference to another error.
*/
public OptimisticLockException() {
}
/**
* Creates a new instance with a reference to the given cause.
*
* @param message the message to show
* @param cause the cause of this error
*/
public OptimisticLockException(String message, Throwable cause) {
super(message, cause);
}
}