You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We also had this mod to Query.withParams to allow Lists and arrays to be passed in:
/**
* Construct a Query with the provided variable number of parameters. Accepts all object types, List, and arrays as parameters.
* @param paramValues
* @return
*/
public Query withParams(Object... paramValues){
int i=0;
for (Object paramValue : paramValues) {
if( paramValue == null ) { // null values are valid for inserting in to a DB . We need to check for these first.
addParameter( "p" + (++i), paramValue );
}
else if( paramValue instanceof Collection ) {
if( paramValue instanceof List ) {
List list = (List) paramValue;
for( Object val : list ) {
addParameter( "p" + (++i), val );
}
}
else {
throw new Sql2oException( "I can only handle ordered Collections - i.e. a List" );
}
}
else if( paramValue.getClass().isArray() ) {
int len = java.lang.reflect.Array.getLength( paramValue );
for( int j = 0; j < len; j++ )
{
Object arrVal = java.lang.reflect.Array.get( paramValue, j );
addParameter( "p" + (++i), arrVal );
}
}
else {
addParameter( "p" + (++i), paramValue );
}
}
return this;
}
The text was updated successfully, but these errors were encountered:
We also had this mod to Query.withParams to allow Lists and arrays to be passed in:
The text was updated successfully, but these errors were encountered: