org.hibernate.Criteria.scroll()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(176)

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

Criteria.scroll介绍

[英]Get the results as an instance of ScrollableResults.
[中]将结果作为ScrollableResults的实例获取。

代码示例

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

@Test
public void testScrollCriteria() {
  Session session = openSession();
  Transaction t = session.beginTransaction();
  Course course = new Course();
  course.setCourseCode("HIB");
  course.setDescription("Hibernate Training");
  session.persist(course);
  session.flush();
  session.clear();
  ScrollableResults sr = session.createCriteria(Course.class).setReadOnly( true ).scroll();
  assertTrue( sr.next() );
  course = (Course) sr.get(0);
  assertNotNull(course);
  assertTrue( session.isReadOnly( course ) );
  sr.close();
  session.delete(course);
  t.commit();
  session.close();
}

代码示例来源:origin: debop/hibernate-redis

@Override
public ScrollableResults scroll(Criteria criteria) {
 return criteria.scroll();
}

代码示例来源:origin: debop/hibernate-redis

@Override
public ScrollableResults scroll(Criteria criteria, ScrollMode scrollMode) {
 return criteria.scroll(scrollMode);
}

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

@Override
public ScrollableResults scroll(final ScrollMode scrollMode) throws HibernateException {
 return criteria.scroll();
}

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

@Override
public ScrollableResults scroll() throws HibernateException {
 return criteria.scroll();
}

代码示例来源:origin: TGAC/miso-lims

@Override
public ScrollableResults scroll(ScrollMode scrollMode) throws HibernateException {
 return backingCriteria.scroll(scrollMode);
}

代码示例来源:origin: TGAC/miso-lims

@Override
public ScrollableResults scroll() throws HibernateException {
 return backingCriteria.scroll();
}

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

ScrollableResults results = session.createCriteria(type).setFetchSize(1000).scroll(ScrollMode.FORWARD_ONLY);
int index = 0;
while (results.next()) {

代码示例来源:origin: 52North/SOS

public static <T> ScrollableIterable<T> fromCriteria(Criteria c) {
  return new ScrollableIterable<>(c.scroll());
}

代码示例来源:origin: org.n52.sensorweb.sos/hibernate-common

public static <T> ScrollableIterable<T> fromCriteria(Criteria c) {
  return new ScrollableIterable<>(c.scroll());
}

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

Criteria criteria = getCurrentSession().createCriteria(LargeVolumeEntity.class);
criteria.add(Restrictions.eq("archived", Boolean.FALSE));
criteria.setReadOnly(true);
criteria.setCacheable(false);
List<E> result = new IterableListScrollableResults<E>(getCurrentSession(),
    criteria.scroll(ScrollMode.FORWARD_ONLY));
for(E entity : result) {
  dumpEntity(file, entity);
}

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

Criteria criteria = getCurrentSession().createCriteria(LargeVolumeEntity.class);
criteria.add(Restrictions.eq("archived", Boolean.FALSE));
criteria.setReadOnly(true);
criteria.setCacheable(false);
List<E> result = new IterableListScrollableResults<E>(getCurrentSession(),
    criteria.scroll(ScrollMode.FORWARD_ONLY));
for(E entity : result) {
  dumpEntity(file, entity);
}

代码示例来源:origin: com.revolsys.open/com.revolsys.open.orm.hibernate

/**
 * Construct a new HibernateQueryPager.
 * 
 * @param criteria The Hibernate criteria.
 */
public HibernateCriteriaPager(final Criteria criteria) {
 this.criteria = criteria;
 final ScrollableResults scrollableResults = criteria.scroll();
 scrollableResults.last();
 this.numResults = scrollableResults.getRowNumber() + 1;
}

代码示例来源:origin: debop/hibernate-redis

@Override
public ScrollableResults scroll(DetachedCriteria dc) {
 return dc.getExecutableCriteria(getSession()).scroll();
}

代码示例来源:origin: debop/hibernate-redis

@Override
public ScrollableResults scroll(DetachedCriteria dc, ScrollMode scrollMode) {
 return dc.getExecutableCriteria(getSession()).scroll(scrollMode);
}

代码示例来源:origin: 52North/SOS

protected void deleteOldValues(String id, Session session) {
  Criteria criteria = session.createCriteria(getHibernateEntityClass());
  criteria.createCriteria(I18nEntity.PROPERTY_ENTITY)
      .add(Restrictions.eq(DescribableEntity.IDENTIFIER, id));
  ScrollableResults scroll = null;
  try {
    scroll = criteria.scroll();
    while (scroll.next()) {
      @SuppressWarnings("unchecked")
      H h18n = (H) scroll.get()[0];
      session.delete(h18n);
    }
  } finally {
    if (scroll != null) {
      scroll.close();
    }
  }
  session.flush();
}

代码示例来源:origin: org.n52.sensorweb.sos/hibernate-common

protected void deleteOldValues(String id, Session session) {
  Criteria criteria = session.createCriteria(getHibernateEntityClass());
  criteria.createCriteria(I18nEntity.PROPERTY_ENTITY)
      .add(Restrictions.eq(DescribableEntity.IDENTIFIER, id));
  ScrollableResults scroll = null;
  try {
    scroll = criteria.scroll();
    while (scroll.next()) {
      @SuppressWarnings("unchecked")
      H h18n = (H) scroll.get()[0];
      session.delete(h18n);
    }
  } finally {
    if (scroll != null) {
      scroll.close();
    }
  }
  session.flush();
}

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

Criteria criteria = ...;
ScrollableResults scroll = criteria.scroll();
Object[] firstRow = scroll.get();  // or use other methods for getting the data
scroll.last();
Object[] lastRow = scroll.get();

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

final Criteria criteria = session.createCriteria(clazz);  
     List<Criterion> restrictions = factory.assemble(command.getFilter());
     for (Criterion restriction : restrictions)
       criteria.add(restriction);
     criteria.add(Restrictions.conjunction());
     if(this.projections != null)
       criteria.setProjection(factory.loadProjections(this.projections));
     criteria.addOrder(command.getDir().equals("ASC")?Order.asc(command.getSort()):Order.desc(command.getSort()));
     ScrollableResults scrollable = criteria.scroll(ScrollMode.SCROLL_INSENSITIVE);
     if(scrollable.last()){//returns true if there is a resultset
       genericDTO.setTotalCount(scrollable.getRowNumber() + 1);
       criteria.setFirstResult(command.getStart())
           .setMaxResults(command.getLimit());
       genericDTO.setLineItems(Collections.unmodifiableList(criteria.list()));
     }
     scrollable.close();
     return genericDTO;

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

@Override
public Flowable<K> publishKeys(Predicate<? super K> filter) {
 return Flowable.using(() -> {
   EntityManager emStream = emf.createEntityManager();
   Session session = emStream.unwrap(Session.class);
   Criteria criteria = session.createCriteria(configuration.entityClass()).setProjection(Projections.id()).setReadOnly(true);
   if (setFetchSizeMinInteger) {
    criteria.setFetchSize(Integer.MIN_VALUE);
   }
   ScrollableResults results = criteria.scroll(ScrollMode.FORWARD_ONLY);
   return new KeyValuePair<>(emStream, results);
 }, kvp -> {
   ScrollableResults results = kvp.getValue();
   return Flowable.fromIterable(() -> new ScrollableResultsIterator(results, filter)
   );
 }, kvp -> {
   try {
    kvp.getValue().close();
   } finally {
    kvp.getKey().close();
   }
 });
}

相关文章