java - Exception Handling and flow -



java - Exception Handling and flow -

i have method , sql query i'm using , particular survey query returns no rows. 'questions' should empty , emptyresultdataaccessexception should thrown (i verified logger.warn(msg) executed in utilize case.) exception should caught in next method.

private void addsurveyquestions(survey survey) throws customexception, dataaccessexception { stringbuilder sql = new stringbuilder(); //build sql query list<surveyquestion> questions = getjdbctemplate().query(sql.tostring(), new object[] { survey.getquestionnairekey() }, new surveyquestionrowmapper()); // should never happen, in case if (questions == null || questions.size() == 0) { string msg = "expected @ to the lowest degree 1 question survey " + survey.getquestionnairekey(); logger.warn(msg); throw new emptyresultdataaccessexception(msg, 1); } // loop through questions - populate multiple selection answers , add together questions survey (surveyquestion q : questions) { //some stuff } survey.addsurveyquestion(q); } }

in method utilize case sql query homecoming 1 row , 'survey' not null , addsurveyquestions(survey) executed should throw emptyresultdataaccessexception. should caught , method homecoming null. never see logger.info("no surveys survey " + surveykey); beingness executed , appears survey object empty surveyquestions list beingness returned (info level logging enabled).

public survey getsurvey(long surveykey) throws customexception { stringbuilder sql = new stringbuilder(); //some sql query seek { // top level container object survey survey = getjdbctemplate().queryforobject(sql.tostring(), new object[] {surveykey }, new surveyrowmapper()); // add together questions , answers if (survey != null) { addsurveyquestions(survey); } homecoming survey; } grab (emptyresultdataaccessexception empty) { // ok,no surveys. logger.info("no surveys survey " + surveykey); homecoming null; } grab (dataaccessexception dae) { string msg = "some message " + surveykey; logger.error(msg); throw new customexception(msg + ", exception: " + dae.getmessage(), dae); } }

any ideas why emptyresultdataaccessexception isn't beingness caught?

java

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -