本文整理了Java中org.hibernate.ScrollableResults.close()
方法的一些代码示例,展示了ScrollableResults.close()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ScrollableResults.close()
方法的具体详情如下:
包路径:org.hibernate.ScrollableResults
类名称:ScrollableResults
方法名:close
[英]Release resources immediately.
[中]立即释放资源。
代码示例来源:origin: spring-projects/spring-data-jpa
@Override
public void close() {
if (scrollableResults != null) {
scrollableResults.close();
}
}
}
代码示例来源:origin: spring-projects/spring-batch
/**
* Close the cursor and hibernate session.
*/
@Override
protected void doClose() throws Exception {
if(initialized) {
if (cursor != null) {
cursor.close();
}
helper.close();
}
initialized = false;
}
}
代码示例来源: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
} finally {
if (scrollableResults != null) {
scrollableResults.close();
代码示例来源: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: hibernate/hibernate-orm
sr.close();
代码示例来源:origin: hibernate/hibernate-orm
assertTrue( "Incorrect return type", obj instanceof Map );
assertEquals( "Incorrect return type", ( (Map) obj ).size(), 2 );
sr.close();
sr.close();
代码示例来源:origin: hibernate/hibernate-orm
results = s.createQuery( "from Item" ).scroll();
results.next();
results.close();
TestingJtaPlatformImpl.INSTANCE.getTransactionManager().commit();
results.close();
TestingJtaPlatformImpl.INSTANCE.getTransactionManager().commit();
代码示例来源:origin: hibernate/hibernate-orm
sr.next();
sr.get(0);
sr.close();
代码示例来源:origin: hibernate/hibernate-orm
assertTrue( "Incorrect return type", sr.get(0) instanceof Animal );
assertFalse( session.contains( sr.get( 0 ) ) );
sr.close();
代码示例来源:origin: hibernate/hibernate-orm
sr.next();
sr.get(0);
sr.close();
代码示例来源:origin: hibernate/hibernate-orm
scrollableResults.close();
tx.commit();
s.close();
代码示例来源:origin: hibernate/hibernate-orm
} finally {
if (scrollableResults != null) {
scrollableResults.close();
代码示例来源:origin: stackoverflow.com
Query query = session.createQuery(query);
query.setReadOnly(true);
// MIN_VALUE gives hint to JDBC driver to stream results
query.setFetchSize(Integer.MIN_VALUE);
ScrollableResults results = query.scroll(ScrollMode.FORWARD_ONLY);
// iterate over results
while (results.next()) {
Object row = results.get();
// process row then release reference
// you may need to evict() as well
}
results.close();
代码示例来源:origin: org.springframework.data/spring-data-jpa
@Override
public void close() {
if (scrollableResults != null) {
scrollableResults.close();
}
}
}
代码示例来源:origin: 52North/SOS
@Override
public void close() throws HibernateException {
try {
this.results.close();
} finally {
this.session.close();
}
}
代码示例来源:origin: org.hibernatespatial/hibernate-spatial
public void close() {
this.tx.commit();
this.results.close();
this.results = null;
this.session.close();
}
代码示例来源:origin: stackoverflow.com
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: stackoverflow.com
Query query = session.createQuery(query);
query.setReadOnly(true);
// MIN_VALUE gives hint to JDBC driver to stream results
query.setFetchSize(Integer.MIN_VALUE);
ScrollableResults results = query.scroll(ScrollMode.FORWARD_ONLY);
// iterate over results
while (results.next()) {
Object row = results.get();
// process row then release reference
// you may need to evict() as well
}
results.close();
代码示例来源:origin: com.querydsl/querydsl-jpa
@Test
public void scroll() {
session.save(new Cat("Bob",10));
session.save(new Cat("Steve",11));
QCat cat = QCat.cat;
HibernateQuery<?> query = new HibernateQuery<Void>(session);
ScrollableResults results = query.from(cat).select(cat).scroll(ScrollMode.SCROLL_INSENSITIVE);
while (results.next()) {
assertNotNull(results.get(0));
}
results.close();
}
内容来源于网络,如有侵权,请联系作者删除!