`
编程足球
  • 浏览: 255138 次
  • 性别: Icon_minigender_1
  • 来自: 福州
社区版块
存档分类
最新评论

org.hibernate.HibernateException: No CurrentSessionContext configured!

阅读更多
在配置好的hibernate中运行时候发现了下面的错误
Exception in thread "main" org.hibernate.HibernateException: No CurrentSessionContext configured!
	at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:620)


上网google下找到解决的方案:
要在hibernate.cfg.xml中session-factory段加入:
1)在集成Hibernate的环境下(例如Jboss),
    <property name="current_session_context_class">jta</property>  


2)在不集成Hibernate的环境下(例如使用JDBC的独立应用程序),、
    <property name="current_session_context_class">thread</property>  
分享到:
评论

相关推荐

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

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

    解决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/...

    HIbernate4.3.6整合c3p0所需jar

    Caused by: org.hibernate.HibernateException: Could not instantiate connection provider [org.hibernate.connection.C3P0ConnectionProvider] at org.hibernate.engine.jdbc.connections.internal....

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

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

    jdbc+hibernate的jar包

    3. `org.hibernate.HibernateException`:Hibernate抛出的异常类。 4. `org.hibernate.Query`和`org.hibernate Criteria`:用于执行HQL(Hibernate Query Language)和Criteria API查询,比直接使用SQL更加灵活。 ...

    Hibernate+Proxool配置

    由于项目需求的需要,我们引入了连接池。...我们采用了Hibernate,所以可以考虑hibernate自带的连接池机制,但是发现效率不高,而且Hibernate也推荐使用c3p0或Proxool连接池,在我们的项目中采用了Proxool

    com.microsoft.sqlserver.jdbc.SQLServerException: 只进结果集不支持请求的操作 解决方案

    query.setHint("org.hibernate.fetchSize", 20); // 设置查询结果集大小 query.setFetchSize(20); List&lt;Game&gt; games = query.list(); tx.commit(); } catch (HibernateException e) { if (tx != null) { tx....

    Hibernate源代码分析

    throw new HibernateException("No CurrentSessionContext configured!"); } return currentSessionContext.currentSession(); } 在 getCurrentSession() 方法中,SessionFactoryImpl 将获取 Session 的工作委托...

    Hibernate配置常见错误

    错误表现:在初始化SessionFactory时,可能出现“org.hibernate.HibernateException: Could not instantiate dialect class”等异常,这通常是因为Hibernate配置文件中的dialect设置不正确或对应的JDBC驱动未引入。...

    Spring4.0+Hibernate4.0+Struts2.3整合案例

    2、报错:org.hibernate.HibernateException: No Session found for current thread 意思是必须在transcation.isActive()条件下才能执行, 可以解决办法是:当方法不需要事务支持的时候,使用 Session ...

    spring_MVC源码

    18. class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"&gt; 19. &lt;property name="dataSource" ref="dataSource" /&gt; 20. &lt;property name="hibernateProperties"&gt; 21. &lt;props&gt; 22...

    Generating Artifacts问题解决.doc

    "GeneratingArtifacts" org.hibernate.HibernateException: ProxoolProvider unable to load JAXP configurator file: proxool_mysql.xml ``` **解析:** 这个错误提示表明,在使用Proxool作为连接池提供者时,...

    Hibernate源代码分析(一)

    throw new HibernateException( "No CurrentSessionContext configured!" ); } return currentSessionContext.currentSession(); } 从上面的代码可以看到,getCurrentSession 方法将获得 Session 对象的工作委托...

    Hibernate开发必备版

    import org.hibernate.HibernateException; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; ``` 2. **类声明:** ```java public class HibernateUtil { ``` 3. **静态...

    hibernate-release-5.4.25.Final_Hibernate5.4.25_hibernate所需jar包_源

    5. 异常处理:Hibernate将SQL异常转换为特定的HibernateException,便于理解和处理。 总之,Hibernate 5.4.25为Java开发者提供了强大的数据持久化解决方案,通过合理的jar包配置和应用,可以极大地提升开发效率,...

    hibernate错误汇总

    错误八:Exception in thread "main" org.hibernate.HibernateException: More than one row with the given identifier was found: 1, for class: org.model.User 错误原因:这个错误表示在尝试获取主键为1的实体...

    J2EE利用Hibernate采用B/S架构网页设计

    import org.hibernate.HibernateException; import org.hibernate.Session; import org.hibernate.cfg.Configuration; /** * Configures and provides access to Hibernate sessions, tied to the * current ...

    学习hibernate第一章内容

    5. 异常体系:理解Hibernate的异常体系,如HibernateException、ConstraintViolationException等。 6. Session和Transaction:理解Session的生命周期和事务管理,以及它们在实际应用中的最佳实践。 本章作为...

Global site tag (gtag.js) - Google Analytics