java - Issue in calling DAO method from Service -


i have dao has method this:

class abcservice  {   private abcdao isntance;   public void getstuff()   {     instance.getqueryresult();   } } 

now if method called anywhere give nullpointerexception instance calls query method. still code in use in project long time , think twice before calling incorrect. there way code can accessed. standard practice?

if have setter isntance, need call before calling getstuff. standard (although needed fields should set inside constructor.


Comments