使用@Autowired for sessionFactory从DHXEventsManager中的数据库获取数据时出现空指针异常

时间:2015-06-22 18:57:09

标签: java spring hibernate dhtmlx-scheduler

当我使用@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;
        }
      }

0 个答案:

没有答案