protected ExceptionConverter getExceptionConverter(){ return producer.getExceptionConverter(); }
@Override public int executeUpdate() throws HibernateException { if ( ! getProducer().isTransactionInProgress() ) { throw getProducer().getExceptionConverter().convert( new TransactionRequiredException( "Executing an update/delete query"
private ExceptionConverter getExceptionConverter(EntityManager em) { return em.unwrap(SharedSessionContractImplementor.class).getExceptionConverter(); }
private ExceptionConverter getExceptionConverter(EntityManager em) { return em.unwrap(SharedSessionContractImplementor.class).getExceptionConverter(); }
private ExceptionConverter getExceptionConverter(EntityManager em) { return em.unwrap(SharedSessionContractImplementor.class).getExceptionConverter(); }
private ExceptionConverter getExceptionConverter(EntityManager em) { return em.unwrap(SharedSessionContractImplementor.class).getExceptionConverter(); }
private ExceptionConverter getExceptionConverter(EntityManager em) { return em.unwrap(SharedSessionContractImplementor.class).getExceptionConverter(); }
private ExceptionConverter getExceptionConverter(EntityManager em) { return em.unwrap(SharedSessionContractImplementor.class).getExceptionConverter(); }
@Override @SuppressWarnings("unchecked") public <T> Parameter<T> getParameter(int position, Class<T> type) { try { final QueryParameter parameter = getParameterMetadata().getQueryParameter( position ); if ( !parameter.getParameterType().isAssignableFrom( type ) ) { throw new IllegalArgumentException( "The type [" + parameter.getParameterType().getName() + "] associated with the parameter corresponding to position [" + position + "] is not assignable to requested Java type [" + type.getName() + "]" ); } return parameter; } catch ( HibernateException e ) { throw getSession().getExceptionConverter().convert( e ); } }
@Override @SuppressWarnings("unchecked") public <T> Parameter<T> getParameter(String name, Class<T> type) { try { final QueryParameter parameter = getParameterMetadata().getQueryParameter( name ); if ( !parameter.getParameterType().isAssignableFrom( type ) ) { throw new IllegalArgumentException( "The type [" + parameter.getParameterType().getName() + "] associated with the parameter corresponding to name [" + name + "] is not assignable to requested Java type [" + type.getName() + "]" ); } return parameter; } catch ( HibernateException e ) { throw getSession().getExceptionConverter().convert( e ); } }
@Override public Parameter<?> getParameter(int position) { try { return getParameterMetadata().getQueryParameter( position ); } catch ( HibernateException e ) { throw getSession().getExceptionConverter().convert( e ); } }
@Override public List<R> list() { beforeQuery(); try { return doList(); } catch (IllegalQueryOperationException e) { throw new IllegalStateException( e ); } catch (TypeMismatchException e) { throw new IllegalArgumentException( e ); } catch (HibernateException he) { throw getSession().getExceptionConverter().convert( he ); } finally { afterQuery(); } }
@Override public Parameter<?> getParameter(String name) { try { return getParameterMetadata().getQueryParameter( name ); } catch ( HibernateException e ) { throw getSession().getExceptionConverter().convert( e ); } }
@Override public boolean execute() { try { final Output rtn = outputs().getCurrent(); return ResultSetOutput.class.isInstance( rtn ); } catch (NoMoreOutputsException e) { return false; } catch (HibernateException he) { throw getSession().getExceptionConverter().convert( he ); } catch (RuntimeException e) { getSession().markForRollbackOnly(); throw e; } }
@Override @SuppressWarnings("unchecked") protected List<R> doList() { if ( getMaxResults() == 0 ) { return Collections.EMPTY_LIST; } try { final Output rtn = outputs().getCurrent(); if ( ! ResultSetOutput.class.isInstance( rtn ) ) { throw new IllegalStateException( "Current CallableStatement ou was not a ResultSet, but getResultList was called" ); } return ( (ResultSetOutput) rtn ).getResultList(); } catch (NoMoreOutputsException e) { // todo : the spec is completely silent on these type of edge-case scenarios. // Essentially here we'd have a case where there are no more results (ResultSets nor updateCount) but // getResultList was called. return null; } catch (HibernateException he) { throw getSession().getExceptionConverter().convert( he ); } catch (RuntimeException e) { getSession().markForRollbackOnly(); throw e; } }
@Override public int getUpdateCount() { try { final Output rtn = outputs().getCurrent(); if ( rtn == null ) { return -1; } else if ( UpdateCountOutput.class.isInstance( rtn ) ) { return ( (UpdateCountOutput) rtn ).getUpdateCount(); } else { return -1; } } catch (NoMoreOutputsException e) { return -1; } catch (HibernateException he) { throw getSession().getExceptionConverter().convert( he ); } catch (RuntimeException e) { getSession().markForRollbackOnly(); throw e; } }
@SuppressWarnings("unchecked") protected <P> QueryParameterBinding<P> locateBinding(Parameter<P> parameter) { if ( parameter instanceof QueryParameter ) { return locateBinding( (QueryParameter) parameter ); } else if ( parameter.getName() != null ) { return locateBinding( parameter.getName() ); } else if ( parameter.getPosition() != null ) { return locateBinding( parameter.getPosition() ); } throw getSession().getExceptionConverter().convert( new IllegalArgumentException( "Could not resolve binding for given parameter reference [" + parameter + "]" ) ); }
@Override public R getSingleResult() { try { final List<R> list = list(); if ( list.size() == 0 ) { throw new NoResultException( "No entity found for query" ); } return uniqueElement( list ); } catch ( HibernateException e ) { if ( getSession().getFactory().getSessionFactoryOptions().isJpaBootstrap() ) { throw getSession().getExceptionConverter().convert( e ); } else { throw e; } } }
@Override @SuppressWarnings("unchecked") public ProcedureCallImplementor<R> registerStoredProcedureParameter(String parameterName, Class type, ParameterMode mode) { getSession().checkOpen( true ); try { registerParameter( parameterName, type, mode ); } catch (HibernateException he) { throw getSession().getExceptionConverter().convert( he ); } catch (RuntimeException e) { getSession().markForRollbackOnly(); throw e; } return this; }
@Override @SuppressWarnings("unchecked") public ProcedureCallImplementor<R> registerStoredProcedureParameter(int position, Class type, ParameterMode mode) { getSession().checkOpen( true ); try { registerParameter( position, type, mode ); } catch (HibernateException he) { throw getSession().getExceptionConverter().convert( he ); } catch (RuntimeException e) { getSession().markForRollbackOnly(); throw e; } return this; }