@Override public int getUpdateCount() { assertExecuted(); return _callback.getUpdateCount(); }
@Override public StoredProcedureQuery setParameter(Parameter<Calendar> param, Calendar cal, TemporalType temporalType) { buildParametersIfNeeded(); _delegate.setParameter(param, cal, temporalType); return this; }
@Override public int executeUpdate() { execute(); return _callback.getUpdateCount(); }
/** * Executes this receiver by delegation to the underlying executable query. * <br> * This method is multi-call safe. The underlying executable query is executed * <em>only</em> for the first invocation. Subsequent */ @Override public boolean execute() { if (_callback == null) { _callback = (QueryResultCallback) getExecutableQuery().execute(_delegate.getParameterValues()); } return _callback.getExecutionResult(); }
/** * Construct a query for executing a Stored Procedure. * @param procedureName name of the database stored procedure. * @param meta * @param delegate the delegate which manages bind parameters on behalf of this */ public StoredProcedureQueryImpl(String procedureName, MultiQueryMetaData meta, QueryImpl<?> delegate) { _name = procedureName; if (!isValidProcedureName(procedureName)) { throw new RuntimeException(procedureName + " is not a valid procedure name"); } _meta = meta; _delegate = delegate; _delegate.compile(); }
/** * Creates a query to execute a Stored Procedure. * <br> * Construction of a {@link StoredProcedureQuery} object is a three step process * <LI> * <LI>a {@link org.apache.openjpa.kernel.Query kernel query} {@code kQ} is created for * {@link QueryLanguages#LANG_SQL SQL} language with the string {@code S} * <LI>a {@link QueryImpl facade query} {@code fQ} is created that delegates to the kernel query {@code kQ} * <LI>a {@link StoredProcedureQueryImpl stored procedure query} is created that delegates to the facade query * {@code fQ}. * <br> * */ private StoredProcedureQuery newProcedure(String procedureName, MultiQueryMetaData meta) { org.apache.openjpa.kernel.QueryImpl kernelQuery = (org.apache.openjpa.kernel.QueryImpl) _broker.newQuery(QueryLanguages.LANG_STORED_PROC, procedureName); kernelQuery.getStoreQuery().setQuery(meta); if (meta != null) { getConfiguration().getMetaDataRepositoryInstance().addQueryMetaData(meta); kernelQuery.setResultMapping(null, meta.getResultSetMappingName()); } return new StoredProcedureQueryImpl(procedureName, meta, new QueryImpl(this, _ret, kernelQuery, meta)); }
/** * Executes this receiver by delegation to the underlying executable query. * <br> * This method is multi-call safe. The underlying executable query is executed * <em>only</em> for the first invocation. Subsequent */ @Override public boolean execute() { if (_callback == null) { _callback = (QueryResultCallback) getExecutableQuery().execute(_delegate.getParameterValues()); } return _callback.getExecutionResult(); }
/** * Construct a query for executing a Stored Procedure. * @param procedureName name of the database stored procedure. * @param meta * @param delegate the delegate which manages bind parameters on behalf of this */ public StoredProcedureQueryImpl(String procedureName, MultiQueryMetaData meta, QueryImpl<?> delegate) { _name = procedureName; if (!isValidProcedureName(procedureName)) { throw new RuntimeException(procedureName + " is not a valid procedure name"); } _meta = meta; _delegate = delegate; _delegate.compile(); }
/** * Creates a query to execute a Stored Procedure. * <br> * Construction of a {@link StoredProcedureQuery} object is a three step process * <LI> * <LI>a {@link org.apache.openjpa.kernel.Query kernel query} {@code kQ} is created for * {@link QueryLanguages#LANG_SQL SQL} language with the string {@code S} * <LI>a {@link QueryImpl facade query} {@code fQ} is created that delegates to the kernel query {@code kQ} * <LI>a {@link StoredProcedureQueryImpl stored procedure query} is created that delegates to the facade query * {@code fQ}. * <br> * */ private StoredProcedureQuery newProcedure(String procedureName, MultiQueryMetaData meta) { org.apache.openjpa.kernel.QueryImpl kernelQuery = (org.apache.openjpa.kernel.QueryImpl) _broker.newQuery(QueryLanguages.LANG_STORED_PROC, procedureName); kernelQuery.getStoreQuery().setQuery(meta); if (meta != null) { getConfiguration().getMetaDataRepositoryInstance().addQueryMetaData(meta); kernelQuery.setResultMapping(null, meta.getResultSetMappingName()); } return new StoredProcedureQueryImpl(procedureName, meta, new QueryImpl(this, _ret, kernelQuery, meta)); }
@Override public StoredProcedureQuery setParameter(Parameter<Date> param, Date value, TemporalType temporalType) { buildParametersIfNeeded(); _delegate.setParameter(param, value, temporalType); return this; }
@Override public int executeUpdate() { execute(); return _callback.getUpdateCount(); }
@Override public int getUpdateCount() { assertExecuted(); return _callback.getUpdateCount(); }
@Override public StoredProcedureQuery setParameter(int position, Object value) { buildParametersIfNeeded(); _delegate.setParameter(position, value); return this; }
@Override public List getResultList() { execute(); try { Object list = _callback.callback(); RuntimeExceptionTranslator trans = PersistenceExceptions .getRollbackTranslator(_delegate.getEntityManager()); return new DelegatingResultList((ResultList) list, trans); } catch (Exception ex) { throw new javax.persistence.PersistenceException(ex); } }
@Override public StoredProcedureQuery setParameter(Parameter<Date> param, Date value, TemporalType temporalType) { buildParametersIfNeeded(); _delegate.setParameter(param, value, temporalType); return this; }
@Override public List getResultList() { execute(); try { Object list = _callback.callback(); RuntimeExceptionTranslator trans = PersistenceExceptions .getRollbackTranslator(_delegate.getEntityManager()); return new DelegatingResultList((ResultList) list, trans); } catch (Exception ex) { throw new javax.persistence.PersistenceException(ex); } }
@Override public Parameter<?> getParameter(int position) { buildParametersIfNeeded(); return _delegate.getParameter(position); }
@Override public Object getSingleResult() { execute(); try { ResultList result = (ResultList) _callback.callback(); if (result == null || result.isEmpty()) throw new NoResultException(_loc.get("no-result", _name) .getMessage()); if (result.size() > 1) throw new NonUniqueResultException(_loc.get("non-unique-result", _name, result.size()).getMessage()); RuntimeExceptionTranslator trans = PersistenceExceptions .getRollbackTranslator(_delegate.getEntityManager()); return new DelegatingResultList(result, trans).iterator().next(); } catch (Exception ex) { throw new javax.persistence.PersistenceException(ex); } }
@Override public StoredProcedureQuery setParameter(String name, Calendar cal, TemporalType temporalType) { buildParametersIfNeeded(); _delegate.setParameter(name, cal, temporalType); return this; }
@Override public Object getSingleResult() { execute(); try { ResultList result = (ResultList) _callback.callback(); if (result == null || result.isEmpty()) throw new NoResultException(_loc.get("no-result", _name) .getMessage()); if (result.size() > 1) throw new NonUniqueResultException(_loc.get("non-unique-result", _name, result.size()).getMessage()); RuntimeExceptionTranslator trans = PersistenceExceptions .getRollbackTranslator(_delegate.getEntityManager()); return new DelegatingResultList(result, trans).iterator().next(); } catch (Exception ex) { throw new javax.persistence.PersistenceException(ex); } }