/** * {@inheritDoc} */ @SuppressWarnings({ "unchecked" }) public <T> Parameter<T> getParameter(int position, Class<T> type) { Parameter param = getParameter( position ); if ( param.getParameterType() != null ) { // we were able to determine the expected type during analysis, so validate it here throw new IllegalArgumentException( "Parameter type [" + param.getParameterType().getName() + "] is not assignment compatible with requested type [" + type.getName() + "]" ); } return param; }
/** * {@inheritDoc} */ @SuppressWarnings({ "unchecked" }) public <T> Parameter<T> getParameter(String name, Class<T> type) { Parameter param = getParameter( name ); if ( param.getParameterType() != null ) { // we were able to determine the expected type during analysis, so validate it here throw new IllegalArgumentException( "Parameter type [" + param.getParameterType().getName() + "] is not assignment compatible with requested type [" + type.getName() + "]" ); } return param; }
/** * {@inheritDoc} */ public Parameter<?> getParameter(int position) { if ( isJpaPositionalParameter( position ) ) { return getParameter( Integer.toString( position ) ); } else { for ( Parameter parameter : parameters ) { if ( parameter.getPosition() != null && position == parameter.getPosition() ) { return parameter; } } throw new IllegalArgumentException( "Unable to locate parameter with position [" + position + "]" ); } }
/** * {@inheritDoc} */ public TypedQuery<X> setParameter(String name, Object value) { try { if ( value instanceof Collection ) { query.setParameterList( name, (Collection) value ); } else { query.setParameter( name, value ); } registerParameterBinding( getParameter( name ), value ); return this; } catch (QueryParameterException e) { throw new IllegalArgumentException( e ); } catch (HibernateException he) { throw getEntityManager().convert( he ); } }
/** * {@inheritDoc} */ public TypedQuery<X> setParameter(int position, Object value) { try { if ( isJpaPositionalParameter( position ) ) { this.setParameter( Integer.toString( position ), value ); } else { query.setParameter( position - 1, value ); registerParameterBinding( getParameter( position ), value ); } return this; } catch (QueryParameterException e) { throw new IllegalArgumentException( e ); } catch (HibernateException he) { throw getEntityManager().convert( he ); } }
/** * {@inheritDoc} */ public TypedQuery<X> setParameter(String name, Calendar value, TemporalType temporalType) { try { if ( temporalType == DATE ) { query.setCalendarDate( name, value ); } else if ( temporalType == TIME ) { throw new IllegalArgumentException( "not yet implemented" ); } else if ( temporalType == TIMESTAMP ) { query.setCalendar( name, value ); } registerParameterBinding( getParameter(name), value ); return this; } catch (QueryParameterException e) { throw new IllegalArgumentException( e ); } catch (HibernateException he) { throw getEntityManager().convert( he ); } }
/** * {@inheritDoc} */ public TypedQuery<X> setParameter(int position, Calendar value, TemporalType temporalType) { try { if ( isJpaPositionalParameter( position ) ) { String name = Integer.toString( position ); this.setParameter( name, value, temporalType ); } else { if ( temporalType == DATE ) { query.setCalendarDate( position - 1, value ); } else if ( temporalType == TIME ) { throw new IllegalArgumentException( "not yet implemented" ); } else if ( temporalType == TIMESTAMP ) { query.setCalendar( position - 1, value ); } registerParameterBinding( getParameter( position ), value ); } return this; } catch (QueryParameterException e) { throw new IllegalArgumentException( e ); } catch (HibernateException he) { throw getEntityManager().convert( he ); } }
/** * {@inheritDoc} */ public TypedQuery<X> setParameter(String name, Date value, TemporalType temporalType) { try { if ( temporalType == DATE ) { query.setDate( name, value ); } else if ( temporalType == TIME ) { query.setTime( name, value ); } else if ( temporalType == TIMESTAMP ) { query.setTimestamp( name, value ); } registerParameterBinding( getParameter( name ), value ); return this; } catch (QueryParameterException e) { throw new IllegalArgumentException( e ); } catch (HibernateException he) { throw getEntityManager().convert( he ); } }
/** * {@inheritDoc} */ public TypedQuery<X> setParameter(int position, Date value, TemporalType temporalType) { try { if ( isJpaPositionalParameter( position ) ) { String name = Integer.toString( position ); this.setParameter( name, value, temporalType ); } else { if ( temporalType == DATE ) { query.setDate( position - 1, value ); } else if ( temporalType == TIME ) { query.setTime( position - 1, value ); } else if ( temporalType == TIMESTAMP ) { query.setTimestamp( position - 1, value ); } registerParameterBinding( getParameter( position ), value ); } return this; } catch (QueryParameterException e) { throw new IllegalArgumentException( e ); } catch (HibernateException he) { throw getEntityManager().convert( he ); } }