关于hibernateCallBack()
public List search(final PetInfo condition, final String orderBy) { return super.getHibernateTemplate().executeFind( new HibernateCallback() { public Object doInHibernate(Session s) throws HibernateException, SQLException { Criteria c = s.createCriteria(PetInfo.class); if (condition != null) { if (condition.getPetOwnerName() != null && !"".equals(condition.getPetOwnerName() .trim())) { c.add(Restrictions.like("petOwnerName", condition.getPetOwnerName(), MatchMode.ANYWHERE)); } if (condition.getPetType() != null && Integer.parseInt(condition.getPetType() .toString()) > 0) { c.add(Restrictions.eq("petType", condition .getPetType())); } } String order = orderBy; order = (null == orderBy || orderBy.trim().equals("")) ? "petName" : orderBy; c.addOrder(Order.asc(order)); List ret = c.list(); return ret; } }); }
java.lang.NullPointerException at com.aptech.jb.epet.dao.hibimpl.PetInfoDaoHibImpl.search(PetInfoDaoHibImpl.java:84) at com.aptech.jb.epet.struts.action.PetAction.doList(PetAction.java:299) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270) at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at com.aptech.jb.epet.filter.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:30) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689) at java.lang.Thread.run(Thread.java:619)