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

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

本文整理了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

/**
 * Applies the {@link LockModeType} provided by the {@link JpaQueryMethod} to the given {@link Query}.
 *
 * @param query must not be {@literal null}.
 * @param method must not be {@literal null}.
 * @return
 */
private Query applyLockMode(Query query, JpaQueryMethod method) {
  LockModeType lockModeType = method.getLockModeType();
  return lockModeType == null ? query : query.setLockMode(lockModeType);
}

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

query.setLockMode(lockMode);

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

query.setLockMode(lockMode);

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

StatelessSession session = ((Session) entityManager.getDelegate()).getSessionFactory().openStatelessSession();
   Query query = session
       .createQuery("SELECT a FROM Address a WHERE .... ORDER BY a.id");
   query.setFetchSize(Integer.valueOf(1000));
   query.setReadOnly(true);
   query.setLockMode("a", LockMode.NONE);
   ScrollableResults results = query.scroll(ScrollMode.FORWARD_ONLY);
   while (results.next()) {
     Address addr = (Address) results.get(0);
     // Do stuff
   }
   results.close();
   session.close();

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

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

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

@Override
public TypedQuery<X> setLockMode(LockModeType arg0)
{
  query.setLockMode(arg0);
  return this;
}

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

public SQL lock(LockModeType mode) {
  query.setLockMode(mode);
  lockMode = mode;
  return this;
}

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

private void rebuildQueryInTransaction() {
  query = entityClass == null ? dbf.getEntityManager().createQuery(sql) : dbf.getEntityManager().createQuery(sql, entityClass);
  if (first != null) {
    query.setFirstResult(first);
  }
  if (lockMode != null) {
    query.setLockMode(lockMode);
  }
  if (max != null) {
    query.setMaxResults(max);
  }
  for (Map.Entry<String, Object> e : params.entrySet()) {
    query.setParameter(e.getKey(), e.getValue());
  }
}

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

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

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

@Override
public Query setLockMode(LockModeType lockMode) {
  underlyingQuery.setLockMode(lockMode);
  return this;
}

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

@Override
  public Query apply(final Query query) {
    return query.setLockMode(lockMode);
  }
});

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

@Override
  public Query postProcess(EntityViewCdiQueryInvocationContext context, Query query) {
    query.setLockMode(lockMode);
    return query;
  }
}

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

@Override
public Query setLockMode(LockModeType lockMode) {
  query.setLockMode(lockMode);
  return this;
}

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

@Override
public Query postProcess(CdiQueryInvocationContext context, Query query)
{
  query.setLockMode(lockMode);
  return query;
}

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

@Override
public Query setLockMode(LockModeType lockMode) {
  underlyingQuery.setLockMode(lockMode);
  return this;
}

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

public Query setLockMode(final LockModeType lockMode) {
  if (!underTx) {
    appliedOperations.add(new QueryOperation() {
      @Override
      public Query apply(final Query query) {
        return query.setLockMode(lockMode);
      }
    });
  }
  return query.setLockMode(lockMode);
}

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

/**
 * Applies the {@link LockModeType} provided by the {@link JpaQueryMethod} to the given {@link Query}.
 *
 * @param query must not be {@literal null}.
 * @param method must not be {@literal null}.
 * @return
 */
private Query applyLockMode(Query query, JpaQueryMethod method) {
  LockModeType lockModeType = method.getLockModeType();
  return lockModeType == null ? query : query.setLockMode(lockModeType);
}

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

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

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

@Override
public long execute() {
  JPQLSerializer serializer = new JPQLSerializer(templates, entityManager);
  serializer.serializeForDelete(queryMixin.getMetadata());
  Map<Object,String> constants = serializer.getConstantToLabel();
  Query query = entityManager.createQuery(serializer.toString());
  if (lockMode != null) {
    query.setLockMode(lockMode);
  }
  JPAUtil.setConstants(query, constants, queryMixin.getMetadata().getParams());
  return query.executeUpdate();
}

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

@Override
public long execute() {
  JPQLSerializer serializer = new JPQLSerializer(templates, entityManager);
  serializer.serializeForUpdate(queryMixin.getMetadata(), updates);
  Map<Object,String> constants = serializer.getConstantToLabel();
  Query query = entityManager.createQuery(serializer.toString());
  if (lockMode != null) {
    query.setLockMode(lockMode);
  }
  JPAUtil.setConstants(query, constants, queryMixin.getMetadata().getParams());
  return query.executeUpdate();
}

相关文章