简体   繁体   中英

getting hibernate session error in java

i have this

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

          Session session = sessionFactory.getCurrentSession();

i get this error

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

You must set your hibernate.current_session_context_class in your hibernate.xml file.

Refer to the following: 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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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