解决方案 »

  1.   

    http://stackoverflow.com/questions/21884701/hibernate-c3p0-throws-nullpointerexception-at-newproxyconnection-commit
    看看能不能找到思路
      

  2.   

    Session session = sessionFactory.getCurrentSession();
    tx = session.beginTransaction();
    chain.doFilter(request, response);
    tx.commit();
    你的chain.doFilter里面应该也sessionFactory.getCurrentSession()了吧,这样能百分百保障开的是同一个连接?
      

  3.   

    public class HibernateSessionFactoryUtil {

    private static SessionFactory sessionFactory;

    private HibernateSessionFactoryUtil(){

    }

    static{

    sessionFactory = new Configuration().configure().buildSessionFactory();
    }

    public static SessionFactory getSessionFactory(){
    return sessionFactory;
    }


    }class GenericDaoHibernate:
    public T findById(PK id) {
    Session session = HibernateSessionFactoryUtil.getSessionFactory().getCurrentSession();
    return (T)session.get(clazz, id);
    }里面的通用方法这样写的
      

  4.   

    chain.doFilter(request, response);应该看下chain.doFilter的实现,某些情况出现null。
      

  5.   


    在没加  ajax代码的时候   刷新页面是没有问题的....会跟我原先的session机制有关吗
      

  6.   


    我是新手,hibernate 框架是根据  51cto学院上的教程修改来的.  问的问题不专业请谅解