У меня есть простое приложение MVC Spring.Я получаю следующее сообщение об ошибке из моего метода контроллера Spring, когда он пытается передать управление JSP.
Вот соответствующая часть моего контроллера.
@Controller
public class ReportsController {
@Autowired
private RecordsService recordsService;
@GetMapping("/reportEmployee")
public String listRecord(Model model) {
model.addAttribute("listRecord", recordsService.reportbyEmployee());
return "report/reportEmployee";
}
}
@Service
public class RecordsServiceImpl implements RecordsService {
@Autowired
private RecordsDAO recordsDAO;
public List<Object[]> reportbyEmployee() {
// TODO Auto-generated method stub
return recordsDAO.reportbyEmployee();
}
}
@Repository
public class RecordsDAOImpl implements RecordsDAO {
@Autowired
private SessionFactory sessionFactory;
@SuppressWarnings("unchecked")
@Transactional(rollbackFor = Exception.class)
public List<Object[]> reportbyEmployee() {
Session session = this.sessionFactory.getCurrentSession();
String hql="SELECT Records.employee.employee_id, SUM(case when Records.type=1 then 1 else 0 end),SUM(case when Records.type=0 then 1 else 0 end)" +
" FROM Records GROUP BY Records.employee.employee_id";
List<Object[]> list = session.createQuery(hql).list();
return list;
}
}
stack
SEVERE: Servlet.service() for servlet [springDispatcherServlet] in context with path [/Assignment] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
java.lang.NullPointerException
at java.lang.String$CaseInsensitiveComparator.compare(Unknown Source)
at java.lang.String$CaseInsensitiveComparator.compare(Unknown Source)
at java.util.TreeMap.getEntryUsingComparator(Unknown Source)
at java.util.TreeMap.getEntry(Unknown Source)
at java.util.TreeMap.get(Unknown Source)
at org.hibernate.dialect.function.SQLFunctionRegistry.findSQLFunction(SQLFunctionRegistry.java:45)
at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.findSQLFunction(SessionFactoryHelper.java:385)
at org.hibernate.hql.internal.ast.tree.IdentNode.getDataType(IdentNode.java:366)
at org.hibernate.hql.internal.ast.HqlSqlWalker.lookupProperty(HqlSqlWalker.java:659)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.propertyRef(HqlSqlBaseWalker.java:1142)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.propertyRefLhs(HqlSqlBaseWalker.java:5794)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.propertyRef(HqlSqlBaseWalker.java:1128)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectExpr(HqlSqlBaseWalker.java:2291)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectExprList(HqlSqlBaseWalker.java:2232)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectClause(HqlSqlBaseWalker.java:1503)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:585)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:313)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:261)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:271)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:191)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:143)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:119)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:153)
Может кто-нибудь пролить свет на это?Это проблема из-за @ Autowrite?