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); } }
/** * Execute a query that returns a single result. */ public X getSingleResult() { _em.assertNotCloseInvoked(); setHint(QueryHints.HINT_RESULT_COUNT, 1); // for DB2 optimization boolean queryFetchPlanUsed = pushQueryFetchPlan(); try { List result = getResultList(); if (result == null || result.isEmpty()) throw new NoResultException(_loc.get("no-result", getQueryString()) .getMessage()); if (result.size() > 1) throw new NonUniqueResultException(_loc.get("non-unique-result", getQueryString(), result.size()).getMessage()); try { return (X)result.get(0); } catch (Exception e) { throw new NoResultException(_loc.get("no-result", getQueryString()) .getMessage()); } } finally { popQueryFetchPlan(queryFetchPlanUsed); } }
/** * Execute a query that returns a single result. */ public X getSingleResult() { _em.assertNotCloseInvoked(); setHint(QueryHints.HINT_RESULT_COUNT, 1); // for DB2 optimization boolean queryFetchPlanUsed = pushQueryFetchPlan(); try { List result = getResultList(); if (result == null || result.isEmpty()) throw new NoResultException(_loc.get("no-result", getQueryString()) .getMessage()); if (result.size() > 1) throw new NonUniqueResultException(_loc.get("non-unique-result", getQueryString(), result.size()).getMessage()); try { return (X)result.get(0); } catch (Exception e) { throw new NoResultException(_loc.get("no-result", getQueryString()) .getMessage()); } } finally { popQueryFetchPlan(queryFetchPlanUsed); } }
/** * Execute a query that returns a single result. */ public X getSingleResult() { _em.assertNotCloseInvoked(); setHint(QueryHints.HINT_RESULT_COUNT, 1); // for DB2 optimization boolean queryFetchPlanUsed = pushQueryFetchPlan(); try { List result = getResultList(); if (result == null || result.isEmpty()) throw new NoResultException(_loc.get("no-result", getQueryString()) .getMessage()); if (result.size() > 1) throw new NonUniqueResultException(_loc.get("non-unique-result", getQueryString(), result.size()).getMessage()); try { return (X)result.get(0); } catch (Exception e) { throw new NoResultException(_loc.get("no-result", getQueryString()) .getMessage()); } } finally { popQueryFetchPlan(queryFetchPlanUsed); } }
/** * Execute a query that returns a single result. */ public X getSingleResult() { _em.assertNotCloseInvoked(); setHint(QueryHints.HINT_RESULT_COUNT, 1); // for DB2 optimization boolean queryFetchPlanUsed = pushQueryFetchPlan(); try { List result = getResultList(); if (result == null || result.isEmpty()) throw new NoResultException(_loc.get("no-result", getQueryString()) .getMessage()); if (result.size() > 1) throw new NonUniqueResultException(_loc.get("non-unique-result", getQueryString(), result.size()).getMessage()); try { return (X)result.get(0); } catch (Exception e) { throw new NoResultException(_loc.get("no-result", getQueryString()) .getMessage()); } } finally { popQueryFetchPlan(queryFetchPlanUsed); } }