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
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
varqueryFormat = "Select * from %s where %s = :value";
returnconnection.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 (IllegalArgumentExceptione) {
thrownewSql2oException("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.
EDIT: Using latest version, 1.6.0
The text was updated successfully, but these errors were encountered:
ghost
changed the title
MethodSetter setProperty failing with i
MethodSetter setProperty failing with generic IllegalArgumentException
Sep 19, 2022
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
The text was updated successfully, but these errors were encountered: