javax.persistence.Query.setLockMode()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(5.0k)|赞(0)|评价(0)|浏览(575)

本文整理了Java中javax.persistence.Query.setLockMode方法的一些代码示例,展示了Query.setLockMode的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setLockMode方法的具体详情如下:
包路径:javax.persistence.Query
类名称:Query
方法名:setLockMode

Query.setLockMode介绍

[英]Set the lock mode type to be used for the query execution.
[中]设置用于查询执行的锁定模式类型。

代码示例

代码示例来源:origin: spring-projects/spring-data-jpa

  1. /**
  2. * Applies the {@link LockModeType} provided by the {@link JpaQueryMethod} to the given {@link Query}.
  3. *
  4. * @param query must not be {@literal null}.
  5. * @param method must not be {@literal null}.
  6. * @return
  7. */
  8. private Query applyLockMode(Query query, JpaQueryMethod method) {
  9. LockModeType lockModeType = method.getLockModeType();
  10. return lockModeType == null ? query : query.setLockMode(lockModeType);
  11. }

代码示例来源:origin: kiegroup/jbpm

  1. query.setLockMode(lockMode);

代码示例来源:origin: kiegroup/jbpm

  1. query.setLockMode(lockMode);

代码示例来源:origin: stackoverflow.com

  1. StatelessSession session = ((Session) entityManager.getDelegate()).getSessionFactory().openStatelessSession();
  2. Query query = session
  3. .createQuery("SELECT a FROM Address a WHERE .... ORDER BY a.id");
  4. query.setFetchSize(Integer.valueOf(1000));
  5. query.setReadOnly(true);
  6. query.setLockMode("a", LockMode.NONE);
  7. ScrollableResults results = query.scroll(ScrollMode.FORWARD_ONLY);
  8. while (results.next()) {
  9. Address addr = (Address) results.get(0);
  10. // Do stuff
  11. }
  12. results.close();
  13. session.close();

代码示例来源:origin: hibernate/hibernate-orm

  1. .setLockMode( LockModeType.PESSIMISTIC_WRITE )
  2. .setParameter( "persons", persons )
  3. .getResultList();

代码示例来源:origin: Impetus/Kundera

  1. @Override
  2. public TypedQuery<X> setLockMode(LockModeType arg0)
  3. {
  4. query.setLockMode(arg0);
  5. return this;
  6. }

代码示例来源:origin: zstackio/zstack

  1. public SQL lock(LockModeType mode) {
  2. query.setLockMode(mode);
  3. lockMode = mode;
  4. return this;
  5. }

代码示例来源:origin: zstackio/zstack

  1. private void rebuildQueryInTransaction() {
  2. query = entityClass == null ? dbf.getEntityManager().createQuery(sql) : dbf.getEntityManager().createQuery(sql, entityClass);
  3. if (first != null) {
  4. query.setFirstResult(first);
  5. }
  6. if (lockMode != null) {
  7. query.setLockMode(lockMode);
  8. }
  9. if (max != null) {
  10. query.setMaxResults(max);
  11. }
  12. for (Map.Entry<String, Object> e : params.entrySet()) {
  13. query.setParameter(e.getKey(), e.getValue());
  14. }
  15. }

代码示例来源:origin: zstackio/zstack

  1. q1.setLockMode(LockModeType.PESSIMISTIC_WRITE);
  2. q1.setParameter("state", ImageCacheState.deleting);
  3. ret.addAll(q1.getResultList());

代码示例来源:origin: org.jboss.eap/wildfly-jpa

  1. @Override
  2. public Query setLockMode(LockModeType lockMode) {
  3. underlyingQuery.setLockMode(lockMode);
  4. return this;
  5. }

代码示例来源:origin: org.apache.openejb/openejb-core

  1. @Override
  2. public Query apply(final Query query) {
  3. return query.setLockMode(lockMode);
  4. }
  5. });

代码示例来源:origin: Blazebit/blaze-persistence

  1. @Override
  2. public Query postProcess(EntityViewCdiQueryInvocationContext context, Query query) {
  3. query.setLockMode(lockMode);
  4. return query;
  5. }
  6. }

代码示例来源:origin: kumuluz/kumuluzee

  1. @Override
  2. public Query setLockMode(LockModeType lockMode) {
  3. query.setLockMode(lockMode);
  4. return this;
  5. }

代码示例来源:origin: org.apache.deltaspike.modules/deltaspike-data-module-impl

  1. @Override
  2. public Query postProcess(CdiQueryInvocationContext context, Query query)
  3. {
  4. query.setLockMode(lockMode);
  5. return query;
  6. }

代码示例来源:origin: org.wildfly/wildfly-jpa

  1. @Override
  2. public Query setLockMode(LockModeType lockMode) {
  3. underlyingQuery.setLockMode(lockMode);
  4. return this;
  5. }

代码示例来源:origin: org.apache.openejb/openejb-core

  1. public Query setLockMode(final LockModeType lockMode) {
  2. if (!underTx) {
  3. appliedOperations.add(new QueryOperation() {
  4. @Override
  5. public Query apply(final Query query) {
  6. return query.setLockMode(lockMode);
  7. }
  8. });
  9. }
  10. return query.setLockMode(lockMode);
  11. }

代码示例来源:origin: org.springframework.data/spring-data-jpa

  1. /**
  2. * Applies the {@link LockModeType} provided by the {@link JpaQueryMethod} to the given {@link Query}.
  3. *
  4. * @param query must not be {@literal null}.
  5. * @param method must not be {@literal null}.
  6. * @return
  7. */
  8. private Query applyLockMode(Query query, JpaQueryMethod method) {
  9. LockModeType lockModeType = method.getLockModeType();
  10. return lockModeType == null ? query : query.setLockMode(lockModeType);
  11. }

代码示例来源:origin: de.mhus.lib/mhu-lib-persistence

  1. /** {@inheritDoc} */
  2. @Override
  3. public JpaQuery<T> setLockMode(LockModeType lockMode) {
  4. return new JpaQuery<T>(entityManager,query.setLockMode(lockMode));
  5. }

代码示例来源:origin: com.querydsl/querydsl-jpa

  1. @Override
  2. public long execute() {
  3. JPQLSerializer serializer = new JPQLSerializer(templates, entityManager);
  4. serializer.serializeForDelete(queryMixin.getMetadata());
  5. Map<Object,String> constants = serializer.getConstantToLabel();
  6. Query query = entityManager.createQuery(serializer.toString());
  7. if (lockMode != null) {
  8. query.setLockMode(lockMode);
  9. }
  10. JPAUtil.setConstants(query, constants, queryMixin.getMetadata().getParams());
  11. return query.executeUpdate();
  12. }

代码示例来源:origin: com.querydsl/querydsl-jpa

  1. @Override
  2. public long execute() {
  3. JPQLSerializer serializer = new JPQLSerializer(templates, entityManager);
  4. serializer.serializeForUpdate(queryMixin.getMetadata(), updates);
  5. Map<Object,String> constants = serializer.getConstantToLabel();
  6. Query query = entityManager.createQuery(serializer.toString());
  7. if (lockMode != null) {
  8. query.setLockMode(lockMode);
  9. }
  10. JPAUtil.setConstants(query, constants, queryMixin.getMetadata().getParams());
  11. return query.executeUpdate();
  12. }

相关文章