org.hibernate.Query.setLockMode()方法的使用及代码示例

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

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

Query.setLockMode介绍

[英]Set the lockmode for the objects idententified by the given alias that appears in the FROM clause.
[中]

代码示例

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

Query q = s.createQuery("from Foo foo, Bar bar");
if ( supportsLockingNullableSideOfJoin( getDialect() ) ) {
  q.setLockMode("bar", LockMode.UPGRADE);
assertTrue( s.getCurrentLockMode(b)==LockMode.NONE );
q = s.createQuery("from Foo foo");
q.setLockMode( "foo", LockMode.READ );
q.list();
assertTrue( s.getCurrentLockMode( b ) == LockMode.READ );
q = s.createQuery("from Foo foo, Bar bar, Bar bar2");
if ( supportsLockingNullableSideOfJoin( getDialect() ) ) {
  q.setLockMode("bar", LockMode.UPGRADE);
q.setLockMode("bar2", LockMode.READ);
result = (Object[]) q.list().get(0);
if ( supportsLockingNullableSideOfJoin( getDialect() ) ) {

代码示例来源:origin: ezbz/projectx

@Override
public Query setLockMode(final String alias, final LockMode lockMode) {
 return query.setLockMode(alias, lockMode);
}

代码示例来源:origin: riotfamily/riot

public TypedQuery<T> setLockMode(String alias, LockMode lockMode) {
  query.setLockMode(alias, lockMode);
  return this;
}

代码示例来源:origin: com.github.cafdataprocessing/corepolicy-hibernate

@Override
public Query setLockMode(String s, LockMode lockMode) {
  return query.setLockMode(s, lockMode);
}

代码示例来源:origin: org.wso2.bpel/ode-dao-hibernate

public boolean lockPremieMessages() {
  try {
    return getSession().getNamedQuery(HCorrelatorMessage.SELECT_CORMESSAGE_BY_MEX).setLockMode("m", LockMode.UPGRADE).setParameter("mex", _hself).list().size() > 0;
  } catch (LockAcquisitionException e) {
    throw new Scheduler.JobProcessorException(e, true);
  }
}

代码示例来源:origin: youseries/uflo

@SuppressWarnings("unchecked")
  public Long execute(Context context) {
    long nextId=0;
    Session session=context.getSession();
    List<ContextProperty> list=session.createQuery("from "+ContextProperty.class.getName()+" as p where p.key=:key").setString("key", ID_KEY).setLockMode("p", LockMode.PESSIMISTIC_WRITE).list();
    if(list.size()>0){
      ContextProperty prop=list.get(0);
      nextId=Long.valueOf(prop.getValue());
      prop.setValue(String.valueOf(nextId+blockSize));
      session.update(prop);
    }else{
      ContextProperty prop=new ContextProperty();
      prop.setKey(ID_KEY);
      prop.setValue(String.valueOf(blockSize));
      session.save(prop);
    }
    return nextId+1;
  }
}

代码示例来源:origin: com.bstek.uflo/uflo-core

@SuppressWarnings("unchecked")
  public Long execute(Context context) {
    long nextId=0;
    Session session=context.getSession();
    List<ContextProperty> list=session.createQuery("from "+ContextProperty.class.getName()+" as p where p.key=:key").setString("key", ID_KEY).setLockMode("p", LockMode.PESSIMISTIC_WRITE).list();
    if(list.size()>0){
      ContextProperty prop=list.get(0);
      nextId=Long.valueOf(prop.getValue());
      prop.setValue(String.valueOf(nextId+blockSize));
      session.update(prop);
    }else{
      ContextProperty prop=new ContextProperty();
      prop.setKey(ID_KEY);
      prop.setValue(String.valueOf(blockSize));
      session.save(prop);
    }
    return nextId+1;
  }
}

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

@Override
public long execute() {
  JPQLSerializer serializer = new JPQLSerializer(templates, null);
  serializer.serializeForUpdate(queryMixin.getMetadata(), updates);
  Map<Object, String> constants = serializer.getConstantToLabel();
  Query query = session.createQuery(serializer.toString());
  for (Map.Entry<Path<?>, LockMode> entry : lockModes.entrySet()) {
    query.setLockMode(entry.getKey().toString(), entry.getValue());
  }
  HibernateUtil.setConstants(query, constants, queryMixin.getMetadata().getParams());
  return query.executeUpdate();
}

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

@Override
public long execute() {
  JPQLSerializer serializer = new JPQLSerializer(templates, null);
  serializer.serializeForDelete(queryMixin.getMetadata());
  Map<Object,String> constants = serializer.getConstantToLabel();
  Query query = session.createQuery(serializer.toString());
  for (Map.Entry<Path<?>, LockMode> entry : lockModes.entrySet()) {
    query.setLockMode(entry.getKey().toString(), entry.getValue());
  }
  HibernateUtil.setConstants(query, constants, queryMixin.getMetadata().getParams());
  return query.executeUpdate();
}

代码示例来源:origin: org.nakedobjects/nos-objectstore-hibernate

query.setLockMode(entry.getKey(), entry.getValue());

代码示例来源:origin: org.wso2.bpel/ode-dao-hibernate

q.setLockMode("hs", LockMode.UPGRADE);

代码示例来源:origin: org.wso2.bpel/ode-dao-hibernate

mcors = qry.setLockMode("this", LockMode.UPGRADE).iterate();
} catch (LockAcquisitionException e) {
  throw new Scheduler.JobProcessorException(e, true);

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

query.setLockMode(entry.getKey().toString(), entry.getValue());

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

query.setLockMode(entry.getKey().toString(), entry.getValue());

相关文章