use of org.hibernate.ScrollableResults in project hibernate-orm by hibernate.
the class HQLScrollFetchTest method testScroll.
@Test
public void testScroll() {
Session s = openSession();
s.beginTransaction();
ScrollableResults results = s.createQuery(QUERY + " order by p.name asc, c.name asc").scroll();
List list = new ArrayList();
while (results.next()) {
list.add(results.get(0));
}
assertResultFromAllUsers(list);
s.getTransaction().commit();
s.close();
}
use of org.hibernate.ScrollableResults in project hibernate-orm by hibernate.
the class HQLScrollFetchTest method testScrollOrderParentAscChildrenAsc.
@Test
@TestForIssue(jiraKey = "HHH-1283")
public void testScrollOrderParentAscChildrenAsc() {
Session s = openSession();
s.beginTransaction();
ScrollableResults results = s.createQuery(QUERY + " order by p.name asc, c.name asc").scroll();
List list = new ArrayList();
while (results.next()) {
list.add(results.get(0));
}
assertResultFromAllUsers(list);
s.getTransaction().commit();
s.close();
}
use of org.hibernate.ScrollableResults in project hibernate-orm by hibernate.
the class HQLScrollFetchTest method testScrollOrderParentAscChildrenDesc.
@Test
@TestForIssue(jiraKey = "HHH-1283")
public void testScrollOrderParentAscChildrenDesc() {
Session s = openSession();
s.beginTransaction();
ScrollableResults results = s.createQuery(QUERY + " order by p.name asc, c.name desc").scroll();
List list = new ArrayList();
while (results.next()) {
list.add(results.get(0));
}
assertResultFromAllUsers(list);
s.getTransaction().commit();
s.close();
}
use of org.hibernate.ScrollableResults in project hibernate-orm by hibernate.
the class HQLScrollFetchTest method testIncompleteScrollSecondResult.
@Test
@TestForIssue(jiraKey = "HHH-1283")
public void testIncompleteScrollSecondResult() {
Session s = openSession();
s.beginTransaction();
ScrollableResults results = s.createQuery(QUERY + " order by p.name asc").scroll();
results.next();
Parent p = (Parent) results.get(0);
assertResultFromOneUser(p);
results.next();
p = (Parent) results.get(0);
assertResultFromOneUser(p);
s.getTransaction().commit();
s.close();
}
use of org.hibernate.ScrollableResults in project hibernate-orm by hibernate.
the class HQLScrollFetchTest method testIncompleteScroll.
@Test
@TestForIssue(jiraKey = "HHH-1283")
public void testIncompleteScroll() {
Session s = openSession();
s.beginTransaction();
ScrollableResults results = s.createQuery(QUERY + " order by p.name asc").scroll();
results.next();
Parent p = (Parent) results.get(0);
assertResultFromOneUser(p);
// get the other parent entity from the persistence context along with its first child
// retrieved from the resultset.
Parent pOther = null;
Child cOther = null;
for (Object entity : ((SessionImplementor) s).getPersistenceContext().getEntitiesByKey().values()) {
if (Parent.class.isInstance(entity)) {
if (entity != p) {
if (pOther != null) {
fail("unexpected parent found.");
}
pOther = (Parent) entity;
}
} else if (Child.class.isInstance(entity)) {
if (!p.getChildren().contains(entity)) {
if (cOther != null) {
fail("unexpected child entity found");
}
cOther = (Child) entity;
}
} else {
fail("unexpected type of entity.");
}
}
// check that the same second parent is obtained by calling Session.get()
assertNull(pOther);
assertNull(cOther);
s.getTransaction().commit();
s.close();
}
Aggregations