`

org.hibernate.HibernateException: No CurrentSessionContext configured!

阅读更多
Exception in thread "main" org.hibernate.HibernateException: No CurrentSessionContext configured!
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:685)
at com.yjw.service.StudentService.main(StudentService.java:19)
原因是hibernate.cfg.xml中没有配置正确,如果是web应用增加配置
Java代码
<property name="current_session_context_class">jta</property> 

如果是Java应用,增加如下配置
Java代码
<property name="current_session_context_class">thread</property> 
分享到:
评论

相关推荐

    解决SpringDataJPA报错:org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null w

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/...

    org.hibernate.HibernateException: No Hibernate Session bound to thread

    然而,在使用 Hibernate 进行数据库操作时,经常会遇到 "No Hibernate Session bound to thread" 的错误信息。本文将详细介绍该错误的解决方案。 错误原因 "No Hibernate Session bound to thread" 错误信息通常是...

    hibernate测试时遇到的几个异常及解决方法汇总

    3. org.hibernate.HibernateException: No CurrentSessionContext configured! 该异常的解决方法是添加 hibernate-jpa-2.0-api-1.0.0.Final.jar。这是因为 Hibernate 需要配置 CurrentSessionContext,以便正确地...

    hibernate-orm.zip

    Hibernate有一套自己的异常体系,如HibernateException、ConstraintViolationException等,这些异常可以帮助开发者快速定位和解决问题。 9. 扩展性与插件机制: Hibernate具有良好的扩展性,如插件化的缓存实现...

    hibernate04.zip

    Hibernate的异常体系主要基于`org.hibernate`包下的异常类,如`HibernateException`、`StaleObjectStateException`等。在编程过程中,应适当地捕获并处理这些异常,确保程序的健壮性。 总结,Hibernate与MySQL的...

Global site tag (gtag.js) - Google Analytics