@SuppressWarnings("unchecked") @Override public List<SLASummaryBean> execute(EntityManager em) throws JPAExecutorException { initPossibleSortbyColumnList(em); createCriteriaQuery(em); TypedQuery<SLASummaryBean> typedQuery = em.createQuery(criteriaQuery); typedQuery.setMaxResults(numMaxResults); LOG.debug("Query string: {0}",typedQuery.unwrap(org.apache.openjpa.persistence.QueryImpl.class).getQueryString()); return typedQuery.getResultList(); }
@SuppressWarnings("unchecked") @Override public List<SLASummaryBean> execute(EntityManager em) throws JPAExecutorException { initPossibleSortbyColumnList(em); createCriteriaQuery(em); TypedQuery<SLASummaryBean> typedQuery = em.createQuery(criteriaQuery); typedQuery.setMaxResults(numMaxResults); LOG.debug("Query string: {0}",typedQuery.unwrap(org.apache.openjpa.persistence.QueryImpl.class).getQueryString()); return typedQuery.getResultList(); }
/** * 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); } }
public int executeUpdate() { _em.assertNotCloseInvoked(); Map<?,?> paramValues = getParameterValues(); if (_query.getOperation() == QueryOperations.OP_DELETE) { return asInt(paramValues.isEmpty() ? _query.deleteAll() : _query.deleteAll(paramValues)); } if (_query.getOperation() == QueryOperations.OP_UPDATE) { return asInt(paramValues.isEmpty() ? _query.updateAll() : _query.updateAll(paramValues)); } throw new InvalidStateException(_loc.get("not-update-delete-query", getQueryString()), null, null, false); }
public int executeUpdate() { _em.assertNotCloseInvoked(); Map<?,?> paramValues = getParameterValues(); if (_query.getOperation() == QueryOperations.OP_DELETE) { return asInt(paramValues.isEmpty() ? _query.deleteAll() : _query.deleteAll(paramValues)); } if (_query.getOperation() == QueryOperations.OP_UPDATE) { return asInt(paramValues.isEmpty() ? _query.updateAll() : _query.updateAll(paramValues)); } throw new InvalidStateException(_loc.get("not-update-delete-query", getQueryString()), null, null, false); }
public int executeUpdate() { _em.assertNotCloseInvoked(); Map<?,?> paramValues = getParameterValues(); if (_query.getOperation() == QueryOperations.OP_DELETE) { return asInt(paramValues.isEmpty() ? _query.deleteAll() : _query.deleteAll(paramValues)); } if (_query.getOperation() == QueryOperations.OP_UPDATE) { return asInt(paramValues.isEmpty() ? _query.updateAll() : _query.updateAll(paramValues)); } throw new InvalidStateException(_loc.get("not-update-delete-query", getQueryString()), null, null, false); }
public int executeUpdate() { _em.assertNotCloseInvoked(); Map<?,?> paramValues = getParameterValues(); if (_query.getOperation() == QueryOperations.OP_DELETE) { return asInt(paramValues.isEmpty() ? _query.deleteAll() : _query.deleteAll(paramValues)); } if (_query.getOperation() == QueryOperations.OP_UPDATE) { return asInt(paramValues.isEmpty() ? _query.updateAll() : _query.updateAll(paramValues)); } throw new InvalidStateException(_loc.get("not-update-delete-query", getQueryString()), null, null, false); }
stats.recordExecution(getQueryString());
private Object execute() { if (!isNative() && _query.getOperation() != QueryOperations.OP_SELECT) throw new InvalidStateException(_loc.get("not-select-query", getQueryString()), null, null, false); try { lock(); Map params = getParameterValues(); boolean registered = preExecute(params); Object result = _query.execute(params); if (registered) { postExecute(result); } return result; } catch (LockTimeoutException e) { throw new QueryTimeoutException(e.getMessage(), new Throwable[]{e}, this); } finally { unlock(); } }
private Object execute() { if (!isNative() && _query.getOperation() != QueryOperations.OP_SELECT) throw new InvalidStateException(_loc.get("not-select-query", getQueryString()), null, null, false); try { lock(); Map params = getParameterValues(); boolean registered = preExecute(params); Object result = _query.execute(params); if (registered) { postExecute(result); } return result; } catch (LockTimeoutException e) { throw new QueryTimeoutException(e.getMessage(), new Throwable[]{e}, this); } finally { unlock(); } }
stats.recordExecution(getQueryString());
private Object execute() { if (!isNative() && _query.getOperation() != QueryOperations.OP_SELECT) throw new InvalidStateException(_loc.get("not-select-query", getQueryString()), null, null, false); try { lock(); Map params = getParameterValues(); boolean registered = preExecute(params); Object result = _query.execute(params); if (registered) { postExecute(result); } return result; } catch (LockTimeoutException e) { throw new QueryTimeoutException(e.getMessage(), new Throwable[]{e}, this); } finally { unlock(); } }
private Object execute() { if (!isNative() && _query.getOperation() != QueryOperations.OP_SELECT) throw new InvalidStateException(_loc.get("not-select-query", getQueryString()), null, null, false); try { lock(); Map params = getParameterValues(); boolean registered = preExecute(params); Object result = _query.execute(params); if (registered) { postExecute(result); } return result; } catch (LockTimeoutException e) { throw new QueryTimeoutException(e.getMessage(), new Throwable[]{e}, this); } finally { unlock(); } }
stats.recordExecution(getQueryString());
stats.recordExecution(getQueryString());