java - Jdbctemplate query: EmptyResultDataAccessException: Incorrect result size: expected 1, actual 0 -
i using jdbctemplate retrieve list of 'spittles' db. here method.
private static final string sql_select_spittle = "select id, spitter_id, spittletext, postedtime spittle"; public list<spittle> getrecentspittles() { return jdbctemplate.query(sql_select_spittle, new rowmapper<spittle>() { public spittle maprow(resultset resultset, int i) throws sqlexception { spittle spittle = new spittle(); spittle.setid(resultset.getlong(1)); spittle.setspitter(getspitterbyid(resultset.getlong(2))); spittle.settext(resultset.getstring(3)); spittle.setwhen(resultset.getdate(4)); return spittle; } }); }
here table database
id spitter_id spittletext postedtime 1 0 hello 2015-08-24 2 4 i've been in london!2015-08-25 3 3 i'm glad 2015-08-28
here stack trace:
info: refreshing org.springframework.context.annotation.annotationconfigapplicationcontext@1b8d17c: startup date [sun aug 30 22:36:35 cest 2015]; root of context hierarchy sie 30, 2015 10:36:36 pm org.springframework.beans.factory.support.defaultlistablebeanfactory registerbeandefinition info: overriding bean definition bean 'jdbctemplatespitterdao' different definition: replacing [generic bean: class [com.gnology.springdataaccess.implementations.jdbctemplatespitterdao]; scope=singleton; abstract=false; lazyinit=false; autowiremode=0; dependencycheck=0; autowirecandidate=true; primary=false; factorybeanname=null; factorymethodname=null; initmethodname=null; destroymethodname=null; defined in file [c:\users\damian\jdbc-project\target\classes\com\gnology\springdataaccess\implementations\jdbctemplatespitterdao.class]] [root bean: class [null]; scope=; abstract=false; lazyinit=false; autowiremode=3; dependencycheck=0; autowirecandidate=true; primary=false; factorybeanname=appconfiguration; factorymethodname=jdbctemplatespitterdao; initmethodname=null; destroymethodname=(inferred); defined in com.gnology.springdataaccess.appconfiguration] sie 30, 2015 10:36:36 pm org.springframework.beans.factory.annotation.autowiredannotationbeanpostprocessor <init> info: jsr-330 'javax.inject.inject' annotation found , supported autowiring exception in thread "main" org.springframework.dao.emptyresultdataaccessexception: incorrect result size: expected 1, actual 0 @ org.springframework.dao.support.dataaccessutils.requiredsingleresult(dataaccessutils.java:71) @ org.springframework.jdbc.core.jdbctemplate.queryforobject(jdbctemplate.java:797) @ com.gnology.springdataaccess.implementations.jdbctemplatespitterdao.getspitterbyid(jdbctemplatespitterdao.java:74) @ com.gnology.springdataaccess.implementations.jdbctemplatespitterdao$2.maprow(jdbctemplatespitterdao.java:94) @ com.gnology.springdataaccess.implementations.jdbctemplatespitterdao$2.maprow(jdbctemplatespitterdao.java:90) @ org.springframework.jdbc.core.rowmapperresultsetextractor.extractdata(rowmapperresultsetextractor.java:93) @ org.springframework.jdbc.core.rowmapperresultsetextractor.extractdata(rowmapperresultsetextractor.java:60) @ org.springframework.jdbc.core.jdbctemplate$1querystatementcallback.doinstatement(jdbctemplate.java:459) @ org.springframework.jdbc.core.jdbctemplate.execute(jdbctemplate.java:404) @ org.springframework.jdbc.core.jdbctemplate.query(jdbctemplate.java:470) @ org.springframework.jdbc.core.jdbctemplate.query(jdbctemplate.java:480) @ com.gnology.springdataaccess.implementations.jdbctemplatespitterdao.getrecentspittles(jdbctemplatespitterdao.java:90) @ com.gnology.springdataaccess.implementations.spitterserviceimpl.getrecentspittles(spitterserviceimpl.java:32) @ com.gnology.springdataaccess.main.main(main.java:19) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:483) @ com.intellij.rt.execution.application.appmain.main(appmain.java:134)
yesterday haven't got problems that, don't know error. how can fix this? in advance.
Comments
Post a Comment