protected void verifyParameters(boolean reserveFirstParameter) throws HibernateException {
if ( parameterMetadata.getNamedParameterNames().size() != namedParameters.size() + namedParameterLists.size() ) {
Set missingParams = new HashSet( parameterMetadata.getNamedParameterNames() );
missingParams.removeAll( namedParameterLists.keySet() );
missingParams.removeAll( namedParameters.keySet() );
throw new QueryException( "Not all named parameters have been set: " + missingParams, getQueryString() );
}
int positionalValueSpan = 0;
for ( int i = 0; i < values.size(); i++ ) {
Object object = types.get( i );
if( values.get( i ) == UNSET_PARAMETER || object == UNSET_TYPE ) {
if ( reserveFirstParameter && i==0 ) {
continue;
}
else {
throw new QueryException( "Unset positional parameter at position: " + i, getQueryString() );
}
}
positionalValueSpan += ( (Type) object ).getColumnSpan( session.getFactory() );
}
if ( parameterMetadata.getOrdinalParameterCount() != positionalValueSpan ) {
if ( reserveFirstParameter && parameterMetadata.getOrdinalParameterCount() - 1 != positionalValueSpan ) {
throw new QueryException(
"Expected positional parameter count: " +
(parameterMetadata.getOrdinalParameterCount()-1) +
", actual parameters: " +
values,
getQueryString()
);
}
else if ( !reserveFirstParameter ) {
throw new QueryException(
"Expected positional parameter count: " +
parameterMetadata.getOrdinalParameterCount() +
", actual parameters: " +
values,
getQueryString()