sql2o is a small library, which makes it easy to convert the result of your sql-statements into objects. No resultset hacking required. Kind of like an orm, but without the sql-generation capabilities. Supports named parameters.
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;
}
We also had this mod to Query.withParams to allow Lists and arrays to be passed in: