Query query = queryManager.createQuery(queryString, Query.SQL); QueryImpl q = (QueryImpl) query; q.setLimit(10); q.setOffset(10); // Start from the 10:th file QueryResult result = q.execute();
public List getResultList() { _em.assertNotCloseInvoked(); Object ob = execute(); if (ob instanceof List) { List ret = (List) ob; if (ret instanceof ResultList) return new DelegatingResultList((ResultList) ret, PersistenceExceptions.getRollbackTranslator(_em)); else return ret; } return Collections.singletonList(ob); }
/** * Execute a query that returns a single result. */ public Object getSingleResult() { _em.assertNotCloseInvoked(); // temporarily set query to unique so that a single result is validated // and returned; unset again in case the user executes query again // via getResultList _query.setUnique(true); try { return execute(); } finally { _query.setUnique(false); } }
public List getResultList() { _em.assertNotCloseInvoked(); boolean queryFetchPlanUsed = pushQueryFetchPlan(); try { Object ob = execute(); if (ob instanceof List) { List ret = (List) ob; if (ret instanceof ResultList) { RuntimeExceptionTranslator trans = PersistenceExceptions.getRollbackTranslator(_em); if (_query.isDistinct()) { return new DistinctResultList((ResultList) ret, trans); } else { return new DelegatingResultList((ResultList) ret, trans); } } else { return ret; } } return Collections.singletonList(ob); } finally { popQueryFetchPlan(queryFetchPlanUsed); } }
public List getResultList() { _em.assertNotCloseInvoked(); boolean queryFetchPlanUsed = pushQueryFetchPlan(); try { Object ob = execute(); if (ob instanceof List) { List ret = (List) ob; if (ret instanceof ResultList) { RuntimeExceptionTranslator trans = PersistenceExceptions.getRollbackTranslator(_em); if (_query.isDistinct()) { return new DistinctResultList((ResultList) ret, trans); } else { return new DelegatingResultList((ResultList) ret, trans); } } else { return ret; } } return Collections.singletonList(ob); } finally { popQueryFetchPlan(queryFetchPlanUsed); } }
public List getResultList() { _em.assertNotCloseInvoked(); boolean queryFetchPlanUsed = pushQueryFetchPlan(); try { Object ob = execute(); if (ob instanceof List) { List ret = (List) ob; if (ret instanceof ResultList) { RuntimeExceptionTranslator trans = PersistenceExceptions.getRollbackTranslator(_em); if (_query.isDistinct()) { return new DistinctResultList((ResultList) ret, trans); } else { return new DelegatingResultList((ResultList) ret, trans); } } else { return ret; } } return Collections.singletonList(ob); } finally { popQueryFetchPlan(queryFetchPlanUsed); } }
public List getResultList() { _em.assertNotCloseInvoked(); boolean queryFetchPlanUsed = pushQueryFetchPlan(); try { Object ob = execute(); if (ob instanceof List) { List ret = (List) ob; if (ret instanceof ResultList) { RuntimeExceptionTranslator trans = PersistenceExceptions.getRollbackTranslator(_em); if (_query.isDistinct()) { return new DistinctResultList((ResultList) ret, trans); } else { return new DelegatingResultList((ResultList) ret, trans); } } else { return ret; } } return Collections.singletonList(ob); } finally { popQueryFetchPlan(queryFetchPlanUsed); } }