org.hibernate.SessionFactory.getCriteriaBuilder()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(130)

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

SessionFactory.getCriteriaBuilder介绍

暂无

代码示例

代码示例来源:origin: geosdi/geo-platform

/**
 * @return {@link CriteriaBuilder}
 */
public final CriteriaBuilder criteriaBuilder() {
  return this.sessionFactory.getCriteriaBuilder();
}

代码示例来源:origin: dhis2/dhis2-core

public CriteriaBuilder getCriteriaBuilder()
{
  return sessionFactory.getCriteriaBuilder();
}

代码示例来源:origin: org.codehaus.griffon.plugins/griffon-hibernate5-core

@Override
public CriteriaBuilder getCriteriaBuilder() {
  return delegate.getCriteriaBuilder();
}

代码示例来源:origin: theonedev/onedev

private long getMaxId(Class<?> entityClass) {
  CriteriaBuilder builder = persistManager.getSessionFactory().getCriteriaBuilder();
  CriteriaQuery<Number> query = builder.createQuery(Number.class);
  Root<?> root = query.from(entityClass);
  query.select(builder.max(root.get("id")));
  Number result = dao.getSession().createQuery(query).getSingleResult();
  return result!=null?result.longValue():0;
}

代码示例来源:origin: theonedev/onedev

@Sessional
@Override
public void exportData(File exportDir, int batchSize) {
  Session session = sessionFactory.openSession();
  for (Class<?> entityType: getEntityTypes(sessionFactory)) {
    logger.info("Exporting table '" + entityType.getSimpleName() + "'...");
    
    logger.info("Querying table ids...");
    
    CriteriaBuilder builder = sessionFactory.getCriteriaBuilder();
    CriteriaQuery<Number> query = builder.createQuery(Number.class);
    Root<?> root = query.from(entityType);
    query.select(root.get("id")).orderBy(builder.asc(root.get("id")));
    
    List<Number> ids = session.createQuery(query).list();
    
    int count = ids.size();
    
    for (int i=0; i<count/batchSize; i++) {
      exportEntity(session, entityType, ids, i*batchSize, batchSize, batchSize, exportDir);
      // clear session to free memory
      session.clear();
    }
    
    if (count%batchSize != 0) {
      exportEntity(session, entityType, ids, count/batchSize*batchSize, count%batchSize, batchSize, exportDir);
    }
    logger.info("");
  }
}

相关文章