aaberg / sql2o

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.
http://sql2o.org
MIT License
1.15k stars 229 forks source link

executeAndFetch NullPointerException #319

Closed daidge closed 5 years ago

daidge commented 5 years ago

members = con.createQuery(sqlFindByIdNumber).addParameter("IdNumber", idnumber).executeAndFetch(Member.class);

java.lang.NullPointerException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.sql2o.reflection.MethodSetter.setProperty(MethodSetter.java:27) at org.sql2o.DefaultResultSetHandlerFactory$4.setProperty(DefaultResultSetHandlerFactory.java:84) at org.sql2o.DefaultResultSetHandlerFactory$6.handle(DefaultResultSetHandlerFactory.java:236) at org.sql2o.PojoResultSetIterator.readNext(PojoResultSetIterator.java:33) at org.sql2o.ResultSetIteratorBase.safeReadNext(ResultSetIteratorBase.java:88) at org.sql2o.ResultSetIteratorBase.hasNext(ResultSetIteratorBase.java:52) at org.sql2o.Query.executeAndFetch(Query.java:598) at org.sql2o.Query.executeAndFetch(Query.java:587) .............

mbraunerDE commented 5 years ago

Could you please provide the Query and the class please ?

daidge commented 5 years ago

public class Member { private String NoBenef; private String Name1; private String Name2; private String Status;

/* Constructor, Getter and Setter
}

final String sqlFindByIdNumber = "SELECT TOP 1 t1.NoBenef, t1.Name1, t1.Name2, t1.Status " + "from table1 t1 inner join table2 t2 on t1.BenefID=t2.BenefID " + "where IdNumber = :IdNumber ";


What 's wrong ?