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.
The method simply propagates the exception without offering any feedback.
Scenario, you make an incorrect column mapping class, let's say that you use java.util.Instant instead of java.sql.timestamp. Everything else is correct, just a type mismatch.
Then you do a simple select
var queryFormat = "Select * from %s where %s = :value";
return connection.createQuery(String.format(queryFormat, tableName, columnName))
.addParameter("value", value)
.setColumnMappings(provideColumnMapping())
.executeAndFetch(clazz); // the class containing the incorrect column type
This eventually goes to: org.sql2o.reflection.MethodSetter#setProperty(Object obj, Object value)
Here, the try catch only cares about IllegalAccessException and InvocationTargetException. The IllegalArgumentException (or any other exception) is ignored and I don't get any feedback on what failed. What class? What method? What type? No idea.
I would expect the following, at least:
...
catch (IllegalArgumentException e) {
throw new Sql2oException("error while calling setter method with name " + method.getName() + " on class " + obj.getClass().toString(), e);
}
But honestly, I'd even go a step further and do this for any exception.
The method simply propagates the exception without offering any feedback.
Scenario, you make an incorrect column mapping class, let's say that you use
java.util.Instant
instead ofjava.sql.timestamp
. Everything else is correct, just a type mismatch.Then you do a simple select
This eventually goes to:
org.sql2o.reflection.MethodSetter#setProperty(Object obj, Object value)
Here, the try catch only cares about
IllegalAccessException
andInvocationTargetException
. TheIllegalArgumentException
(or any other exception) is ignored and I don't get any feedback on what failed. What class? What method? What type? No idea.I would expect the following, at least:
But honestly, I'd even go a step further and do this for any exception.
EDIT: Using latest version,
1.6.0