繁体   English   中英

在java中获取休眠会话错误

[英]getting hibernate session error in java

我有这个

SessionFactory sessionFactory = new AnnotationConfiguration()
        .configure("com/vaannila/service/hibernate.cfg.xml")
        .buildSessionFactory();

          Session session = sessionFactory.getCurrentSession();

我得到这个错误

org.hibernate.HibernateException: No CurrentSessionContext configured!
    org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:542)

您必须在hibernate.xml文件中设置hibernate.current_session_context_class。

请参阅以下内容: http : //docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html#configuration-j2ee-currentsession

在cfg文件中有此条目。

<property name="hibernate.current_session_context_class">thread</property>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM