1. 程式人生 > >使用DAO時發生空指標錯誤

使用DAO時發生空指標錯誤

2014-10-6 17:38:26 dao.daoImpl.CustomerDAO save
嚴重: save failed
java.lang.NullPointerException
at dao.daoImpl.CustomerDAO.save(CustomerDAO.java:51)
at test.CustomerDAOtest.testSave(CustomerDAOtest.java:48)
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)

原因之一:

沒有啟動SPRING容器或者是hibernate容器

到時了sessionFactory沒有注入到Dao中···所以呼叫SAVE()時候發生空指標異常