Exemple #1
0
 public <V> V executeScalar(Class returnType) {
   Object value = executeScalar();
   Converter converter = null;
   try {
     converter = Convert.getConverter(returnType);
     return (V) converter.convert(value);
   } catch (ConverterException e) {
     throw new Sql2oException(
         "Error occured while converting value from database to type " + returnType.toString(), e);
   }
 }
Exemple #2
0
 @SuppressWarnings("unchecked")
 private Object convertParameter(Object value) {
   if (value == null) {
     return null;
   }
   Converter converter = getQuirks().converterOf(value.getClass());
   if (converter == null) {
     // let's try to add parameter AS IS
     return value;
   }
   return converter.toDatabaseParam(value);
 }
Exemple #3
0
 public <V> V executeScalar(Converter<V> converter) {
   try {
     //noinspection unchecked
     return converter.convert(executeScalar());
   } catch (ConverterException e) {
     throw new Sql2oException("Error occured while converting value from database", e);
   }
 }