本文整理了Java中org.hibernate.Query.setLockOptions
方法的一些代码示例,展示了Query.setLockOptions
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setLockOptions
方法的具体详情如下:
包路径:org.hibernate.Query
类名称:Query
方法名:setLockOptions
[英]Set the lock options for the query. Specifically only the following are taken into consideration:
代码示例来源:origin: com.github.cafdataprocessing/corepolicy-hibernate
@Override
public Query setLockOptions(LockOptions lockOptions) {
return query.setLockOptions(lockOptions);
}
代码示例来源:origin: riotfamily/riot
public TypedQuery<T> setLockOptions(LockOptions lockOptions) {
query.setLockOptions(lockOptions);
return this;
}
代码示例来源:origin: ezbz/projectx
@Override
public Query setLockOptions(final LockOptions lockOptions) {
return query.setLockOptions(lockOptions);
}
代码示例来源:origin: com.isotrol.impe3/impe3-pms-core
private <T extends PublishableEntity<T, ?, ?>> Iterable<T> getPFM(String queryName, Class<T> type) {
final Query q = getNamedQuery(queryName).setLockOptions(LockOptions.UPGRADE);
return list(type, q);
}
代码示例来源:origin: vladmihalcea/high-performance-java-persistence
@Test
public void testPessimisticWrite() {
LOGGER.info("Test lock contention");
doInJPA(entityManager -> {
List<Post> pendingPosts = entityManager.createQuery(
"select p " +
"from Post p " +
"where p.status = :status",
Post.class)
.setParameter("status", PostStatus.PENDING)
.setMaxResults(5)
//.setLockMode(LockModeType.PESSIMISTIC_WRITE)
.unwrap(org.hibernate.Query.class)
.setLockOptions(new LockOptions(LockMode.PESSIMISTIC_WRITE).setTimeOut(LockOptions.SKIP_LOCKED))
.list();
assertEquals(5, pendingPosts.size());
});
}
代码示例来源:origin: vladmihalcea/high-performance-java-persistence
@Test
@Ignore
public void testUpgradeSkipLockedOrderByMaxResult() {
LOGGER.info("Test lock contention");
doInJPA(entityManager -> {
List<Post> pendingPosts = entityManager.createQuery(
"select p " +
"from Post p " +
"where p.status = :status " +
"order by p.id ",
Post.class)
.setParameter("status", PostStatus.PENDING)
.setMaxResults(5)
.unwrap(org.hibernate.Query.class)
.setLockOptions(new LockOptions(LockMode.UPGRADE_SKIPLOCKED))
.list();
assertEquals(3, pendingPosts.size());
});
}
代码示例来源:origin: vladmihalcea/high-performance-java-persistence
@Test
public void testUpgradeSkipLocked() {
LOGGER.info("Test lock contention");
doInJPA(entityManager -> {
List<Post> pendingPosts = entityManager.createQuery(
"select p " +
"from Post p " +
"where p.status = :status",
Post.class)
.setParameter("status", PostStatus.PENDING)
.setFirstResult(2)
.unwrap(org.hibernate.Query.class)
.setLockOptions(new LockOptions(LockMode.UPGRADE_SKIPLOCKED))
.list();
assertEquals(3, pendingPosts.size());
});
}
代码示例来源:origin: vladmihalcea/high-performance-java-persistence
@Test
public void testUpgradeSkipLockedOrderBy() {
LOGGER.info("Test lock contention");
doInJPA(entityManager -> {
List<Post> pendingPosts = entityManager.createQuery(
"select p " +
"from Post p " +
"where p.status = :status " +
"order by p.id ",
Post.class)
.setParameter("status", PostStatus.PENDING)
.setFirstResult(2)
.unwrap(org.hibernate.Query.class)
.setLockOptions(new LockOptions(LockMode.UPGRADE_SKIPLOCKED))
.list();
assertEquals(3, pendingPosts.size());
});
}
内容来源于网络,如有侵权,请联系作者删除!