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
Dalesbred is an elegant light-weigth JDBC framework, I use it on my project, and database is mysql, when I query data from table via findAll() method I encounter "java.lang.IllegalArgumentException: null" if there is null field on the return row, hope that we can fix this issue as soon as possible. Thx.
java.lang.IllegalArgumentException: null
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_25]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_25]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_25]
at java.lang.reflect.Constructor.newInstance(Constructor.java:408) ~[na:1.8.0_25]
at org.dalesbred.internal.instantiation.ReflectionInstantiator.instantiate(ReflectionInstantiator.java:62) ~[dalesbred-1.2.2.jar:na]
at org.dalesbred.internal.result.InstantiatorRowMapper.mapRow(InstantiatorRowMapper.java:76) ~[dalesbred-1.2.2.jar:na]
at org.dalesbred.result.RowMapper.lambda$list$22(RowMapper.java:59) ~[dalesbred-1.2.2.jar:na]
at org.dalesbred.result.RowMapper$$Lambda$40/852687460.process(Unknown Source) ~[na:na]
at org.dalesbred.Database.lambda$executeQuery$1(Database.java:287) [dalesbred-1.2.2.jar:na]
at org.dalesbred.Database$$Lambda$41/951880373.execute(Unknown Source) ~[na:na]
at org.dalesbred.transaction.DefaultTransaction.execute(DefaultTransaction.java:53) ~[dalesbred-1.2.2.jar:na]
at org.dalesbred.transaction.DefaultTransactionManager.withNewTransaction(DefaultTransactionManager.java:61) [dalesbred-1.2.2.jar:na]
at org.dalesbred.transaction.AbstractTransactionManager.withTransaction(AbstractTransactionManager.java:62) [dalesbred-1.2.2.jar:na]
at org.dalesbred.Database.withTransaction(Database.java:201) [dalesbred-1.2.2.jar:na]
at org.dalesbred.Database.withTransaction(Database.java:190) [dalesbred-1.2.2.jar:na]
at org.dalesbred.Database.withTransaction(Database.java:162) [dalesbred-1.2.2.jar:na]
at org.dalesbred.Database.withCurrentTransaction(Database.java:264) [dalesbred-1.2.2.jar:na]
at org.dalesbred.Database.executeQuery(Database.java:278) [dalesbred-1.2.2.jar:na]
at org.dalesbred.Database.findAll(Database.java:325) [dalesbred-1.2.2.jar:na]
at org.dalesbred.Database.findAll(Database.java:333) [dalesbred-1.2.2.jar:na]
at test.TestDalesbred.main(TestDalesbred.java:51) [main/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_25]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_25]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_25]
at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_25]
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) [idea_rt.jar:na]
The text was updated successfully, but these errors were encountered:
radiumweilei
changed the title
null field will lead to "java.lang.IllegalArgumentException: null"
Null field will lead to "java.lang.IllegalArgumentException: null"
Oct 19, 2016
Based on the stacktrace, I'm pretty sure that you have a constructor that requires a primitive value, but null is returned from database and therefore the constructor throws (or rather the reflection machinery trying to invoke the constructor throws).
Of course you'll achieve a similar result even without reflection by saying: new Foo((Integer) null).
So if constructor requires non-null value, but Dalesbred only has a null, what should it do? Isn't throwing an exception the only reasonable thing to do?
So either create a constructor that allows null values (e.g. requiring Integer instead of int or something similar) or you coalesce or similar in the database so you don't get a null back int he first place.
If I'm completely wrong about this, then I'm going to need some more details (example source code) to reproduce the bug.
Thanks Komu, I can fix this issue after follow your advice by use primitive wrapper class to instead of primitive data type, that a good news, Thank you very much.
Hi,
Dalesbred is an elegant light-weigth JDBC framework, I use it on my project, and database is mysql, when I query data from table via findAll() method I encounter "java.lang.IllegalArgumentException: null" if there is null field on the return row, hope that we can fix this issue as soon as possible. Thx.
java.lang.IllegalArgumentException: null
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_25]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_25]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_25]
at java.lang.reflect.Constructor.newInstance(Constructor.java:408) ~[na:1.8.0_25]
at org.dalesbred.internal.instantiation.ReflectionInstantiator.instantiate(ReflectionInstantiator.java:62) ~[dalesbred-1.2.2.jar:na]
at org.dalesbred.internal.result.InstantiatorRowMapper.mapRow(InstantiatorRowMapper.java:76) ~[dalesbred-1.2.2.jar:na]
at org.dalesbred.result.RowMapper.lambda$list$22(RowMapper.java:59) ~[dalesbred-1.2.2.jar:na]
at org.dalesbred.result.RowMapper$$Lambda$40/852687460.process(Unknown Source) ~[na:na]
at org.dalesbred.Database.lambda$executeQuery$1(Database.java:287) [dalesbred-1.2.2.jar:na]
at org.dalesbred.Database$$Lambda$41/951880373.execute(Unknown Source) ~[na:na]
at org.dalesbred.transaction.DefaultTransaction.execute(DefaultTransaction.java:53) ~[dalesbred-1.2.2.jar:na]
at org.dalesbred.transaction.DefaultTransactionManager.withNewTransaction(DefaultTransactionManager.java:61) [dalesbred-1.2.2.jar:na]
at org.dalesbred.transaction.AbstractTransactionManager.withTransaction(AbstractTransactionManager.java:62) [dalesbred-1.2.2.jar:na]
at org.dalesbred.Database.withTransaction(Database.java:201) [dalesbred-1.2.2.jar:na]
at org.dalesbred.Database.withTransaction(Database.java:190) [dalesbred-1.2.2.jar:na]
at org.dalesbred.Database.withTransaction(Database.java:162) [dalesbred-1.2.2.jar:na]
at org.dalesbred.Database.withCurrentTransaction(Database.java:264) [dalesbred-1.2.2.jar:na]
at org.dalesbred.Database.executeQuery(Database.java:278) [dalesbred-1.2.2.jar:na]
at org.dalesbred.Database.findAll(Database.java:325) [dalesbred-1.2.2.jar:na]
at org.dalesbred.Database.findAll(Database.java:333) [dalesbred-1.2.2.jar:na]
at test.TestDalesbred.main(TestDalesbred.java:51) [main/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_25]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_25]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_25]
at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_25]
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) [idea_rt.jar:na]
The text was updated successfully, but these errors were encountered: