Hi shrutee,
According to the error log, the system is unable to create the named query associated with com.test.dao.Dfp1CarClassDAOImpl.findAllDfp1CarClasss():
java.lang.NullPointerException
at org.skyway.spring.util.dao.AbstractJpaDao.createNamedQuery(AbstractJpaDao.java:214)
at org.skyway.spring.util.dao.AbstractJpaDao.createNamedQuery(AbstractJpaDao.java:205)
at com.test.dao.Dfp1CarClassDAOImpl.findAllDfp1CarClasss(Dfp1CarClassDAOImpl.java:247)
at com.test.datamodel.LazyCarList.fetchLazyData(LazyCarList.java:27)
The line in AbstractJPADao.java that is failing with a Null Pointer Exception is this:
Query query = getEntityManager().createNamedQuery(queryName);
Likely the EntityManager is null because you’ve tried calling the dao method from a bean that is not properly wired into spring. In your LazyCarList.fetchLazyData, you are constructing a DaoImpl. When you manually construct the DaoImpl it doesn’t get the spring context and the entity manager is not autowired in.
Can you move your method into the existing scaffolded objects, maybe the scaffolded class annotated with @Component? Or, possibly try annotating the LazyCarList with @Component and then use autowiring for the dao? You should find examples in the scaffolded code of how a dao is autowired in and then called.
HTH