Here are the examples of the java api org.hibernate.LockMode.FORCE taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2 Examples
19
Source : AbstractEntityEntry.java
with GNU General Public License v2.0
from lamsfoundation
with GNU General Public License v2.0
from lamsfoundation
@Override
public void forceLocked(Object enreplacedy, Object nextVersion) {
version = nextVersion;
loadedState[persister.getVersionProperty()] = version;
// TODO: use LockMode.PESSIMISTIC_FORCE_INCREMENT
// noinspection deprecation
setLockMode(LockMode.FORCE);
persister.setPropertyValue(enreplacedy, getPersister().getVersionProperty(), nextVersion);
}
18
Source : ReactiveSessionTest.java
with GNU Lesser General Public License v2.1
from hibernate
with GNU Lesser General Public License v2.1
from hibernate
@Test
public void reactiveFindWithPessimisticIncrementLock(TestContext context) {
final GuineaPig expectedPig = new GuineaPig(5, "Aloi");
test(context, populateDB().thenCompose(v -> getSessionFactory().withTransaction((session, transaction) -> session.find(GuineaPig.clreplaced, expectedPig.getId(), LockMode.PESSIMISTIC_FORCE_INCREMENT).thenAccept(actualPig -> {
replacedertThatPigsAreEqual(context, expectedPig, actualPig);
// grrr, lame
context.replacedertEquals(session.getLockMode(actualPig), LockMode.FORCE);
context.replacedertEquals(1, actualPig.version);
}))).thenApply(v -> openSession()).thenCompose(session -> session.find(GuineaPig.clreplaced, expectedPig.getId())).thenAccept(actualPig -> context.replacedertEquals(1, actualPig.version)));
}