当我使用@Futowired注释SessionFactory在使用DHXEventsManager时从数据库中检索数据时,发生了java.lang.NullPointerException。我无法修复它。请任何人帮忙!
package com.dhtmlx.booking.controller;
import javax.servlet.http.HttpServletRequest;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import com.dhtmlx.planner.DHXEv;
import com.dhtmlx.planner.DHXEventsManager;
import com.dhtmlx.planner.DHXStatus;
import com.dhtmlx.planner.data.DHXCollection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class CustomEventsManager extends DHXEventsManager {
@Autowired
SessionFactory sessionfactory;
public CustomEventsManager(HttpServletRequest request) {
super(request);
}
public Iterable<DHXEv> getEvents() {
List<DHXEv> evs = new ArrayList<DHXEv>();
try {
evs = sessionfactory.getCurrentSession().createCriteria(Event.class).list();
} catch (RuntimeException e) {
e.printStackTrace();
}
return evs;
}
}