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

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

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

Query.setFlushMode介绍

set the current FlushMode in effect for this query.
[中](重新)为此查询设置有效的当前刷新模式。

代码示例

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

protected void setQueryProperties(Query query) {
  if ( maxResults != null ) {
    query.setMaxResults( maxResults );
  }
  if ( firstResult != null ) {
    query.setFirstResult( firstResult );
  }
  if ( cacheable != null ) {
    query.setCacheable( cacheable );
  }
  if ( cacheRegion != null ) {
    query.setCacheRegion( cacheRegion );
  }
  if ( comment != null ) {
    query.setComment( comment );
  }
  if ( flushMode != null ) {
    query.setFlushMode( flushMode );
  }
  if ( cacheMode != null ) {
    query.setCacheMode( cacheMode );
  }
  if ( timeout != null ) {
    query.setTimeout( timeout );
  }
  if ( lockOptions != null && lockOptions.getLockMode() != LockMode.NONE ) {
    query.setLockMode( REFERENCED_ENTITY_ALIAS, lockOptions.getLockMode() );
  }
}

代码示例来源:origin: org.nuiton.topia/topia-persistence

protected Query prepareQuery(String jpaql, Map<String, Object> parameters) {
  checkHqlParameters(parameters);
  Query query = hibernateSupport.getHibernateSession().createQuery(jpaql);
  for (Map.Entry<String, Object> entry : parameters.entrySet()) {
    String name = entry.getKey();
    Object value = entry.getValue();
    if (value.getClass().isArray()) {
      query.setParameterList(name, (Object[]) value);
    } else if (value instanceof Collection<?>) {
      query.setParameterList(name, (Collection<?>) value);
    } else {
      query.setParameter(name, value);
    }
  }
  // tchemit 2010-11-30 reproduce the same behaviour than before with the dao legacy
  if (useFlushMode) { // FIXME AThimel 06/08/14 I think this is the reason of the unexpected flush we have
    query.setFlushMode(FlushMode.AUTO);
  }
  return query;
}

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

query.setFlushMode( flushModeType );

相关文章