java - nullpointer exception when querying database -
i trying query database hibernate project
public class feedinputparamsdaoimpl implements ifeedinputparamsdao { @autowired private sessionfactory sessionfactory; public void setsessionfactory(sessionfactory sessionfactory) { this.sessionfactory = sessionfactory; } private int batch_size = 50; public session getsession() { /*null pointer exception*/session session = sessionfactory.opensession(); return session; } @override public list<feedinputparams> getallfeedinputparamslist (int feedkey) { string querystring = "from feedinputparams feedinputparams feedinputparams.feedkey > ?"; session session = getsession(); query query = session.createquery(querystring); query.setparameter(0, feedkey); list<feedinputparams> feedinputparamslist = query.list(); return feedinputparamslist; } }
and getallfeedinputparamslist (int feedkey) called method
public void readfile() throws exception { feedinputparamsdaoimpl feedinputparamsdaoimpl=new feedinputparamsdaoimpl(); list<feedinputparams> feedinputparamslist=feedinputparamsdaoimpl.getallfeedinputparamslist(0); system.out.println("feedinputparamslist...."+feedinputparamslist); }
i getting null pointer exception
java.lang.nullpointerexception @ com.vxl.appanalytix.dao.impl.feedinputparamsdaoimpl.getsession(feedinputparamsdaoimpl.java:28) @ com.vxl.appanalytix.dao.impl.feedinputparamsdaoimpl.getallfeedinputparamslist(feedinputparamsd0impl.java:44) @
sessionfactory null - not autowired spring reason. have annotation on feedinputparamsdaoimpl class?
Comments
Post a Comment