`

关于Hibernate中调用集合类时出现的 the owning Session was closed 错误解决方案

阅读更多
错误异常:

08:42:43,546 ERROR LazyInitializationException:19 - could not initialize proxy - the owning Session was closed
org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:60)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:172)


解决方案:
hibernate默认是延迟加载,而导致无法将集合类中数据读取出来

则可以在相应pojo对应的hbm.xml文件里做出相关修改
1 可以在hibernate-mapping标签中设置属性default-lazy="false"
2 也可以在class标签中设置属性lazy="false"
以上都可以解决问题
分享到:
评论

相关推荐

    Hibernate映射导致的几个异常

    Could not initialize proxy - the owning Session was closed 这是Hibernate懒加载机制中的常见异常,当尝试访问一个已被关闭的Session中的懒加载属性时触发。例如,如果Session在使用`setFetchMode(FetchMode....

    Hibernate延迟加载以及利用Spring

    Exception in thread "main" org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed ``` - **日志记录**:为了更好地诊断问题,可以使用log4j等工具进行日志...

    数位板压力测试

    The availability of drivers that support the features of the specification will simplify the process of developing Windows appli¬cation programs that in-corporate absolute coordinate input, and ...

    Hibernate关联关系疑问

    在IT行业中,Hibernate是一个非常重要的Java持久化框架,它简化了数据库操作,使得开发者可以更加专注于业务逻辑,而不是底层的数据访问细节。这篇博客"Hibernate关联关系疑问"可能探讨了在使用Hibernate处理对象...

    Cohen-Game-Of-Chromes-Owning-The-Web-With-Zombie-Chrome-Extensio

    《Cohen-Game-Of-Chromes-Owning-The-Web-With-Zombie-Chrome-Extensions》这篇文章主要探讨了网络安全领域的一个重要问题:利用僵尸Chrome扩展程序对Web的控制。Chrome浏览器作为全球最流行的浏览器之一,其扩展...

    Cohen-Game-Of-Chromes-Owning-The-Web-With-Zombie-Chrome-Extens

    标题和描述中提到的“Cohen-Game-Of-Chromes-Owning-The-Web-With-Zombie-Chrome-Extens”以及“Owning the Web with Zombie Chrome Extensions”涉及了一系列关于恶意Chrome浏览器扩展(称为“僵尸扩展”)的研究,...

    「安全资讯」hta-t07_modern-exploitation-owning-all-of-the-things -

    「安全资讯」hta-t07_modern-exploitation-owning-all-of-the-things - 数据安全 漏洞分析 漏洞预警 WEB应用防火墙 工控安全 安全管理

    inverse=true的总结

    在IT行业中,尤其是在Java开发或者使用ORM框架(如Hibernate)时,“inverse=true”是一个非常重要的概念,它涉及到对象关系映射中的数据管理策略。本文将深入解析“inverse=true”的含义,以及它在实际应用中的作用...

    Argyroudis_Exploiting_the_ jemalloc_Memory_ Allocator_WP.pdf

    每个线程首次调用jemalloc时会被分配到一个特定的Arena上进行内存操作。Arena之间的数据结构独立,每个Arena内部有自己的管理机制。 ##### 内部数据结构 jemalloc内部主要由Arena、Bin、Chunk等组成: - **Arena*...

    博士面试英文自我介绍3分钟范文.pdf,这是一份不错的文件

    Owning to my hard work, I was rewarded the Excellent Prize in the successive three years. However, with time going on, the more I experienced, the clearer I realized that I am really interested in ...

    HibernateOneOneBidirectionalForeignkey:Hibernate OneOne双向外键

    在Java的持久化框架Hibernate中,一对一(OneToOne)关系是一种常见的关联映射方式,尤其在处理数据库表之间一对一关联的场景下。本教程将详细探讨Hibernate中的双向外键(Bidirectional Foreign Key)配置,以及...

    信息安全_数据安全_Owning Your Professional Narrative.pdf

    Camille Stewart在其演讲"Owning Your Professional Narrative"中强调了如何有效地管理和表达自己的专业故事,这对于网络安全专家尤其重要,因为这不仅关乎个人成长,也影响着安全工作的执行和效果。 首先,确定3-5...

    Process Explorer

    The top window always shows a list of the currently active processes, including the names of their owning accounts, whereas the information displayed in the bottom window depends on the mode that ...

    ProcessExplorer

    The top window always shows a list of the currently active processes, including the names of their owning accounts, whereas the information displayed in the bottom window depends on the mode that ...

    高中英语 Unit 5 Music全员探究 新人教版必修2

    例如:"The singer came into the hall with many fans following him." 描述歌手进入大厅时粉丝跟随着的情景。在题目中的句子 "with everyone clapping and enjoying singing",它描绘了在音乐会中人们热烈鼓掌、...

    procexp.zip

    The top window always shows a list of the currently active processes, including the names of their owning accounts, whereas the information displayed in the bottom window depends on the mode that ...

    高一英语必修3期末考试题.docx

    It is practically the same as ______ of a new motorcycle." 这里的"that"用来指代前面提到的"the price",在比较结构中,为了避免重复,常用that或those代替前面出现的可数名词单数或复数形式。 5. 名词的单...

    09新东方在线考研英语强化班阅读讲义

    In the American economic system, individuals choose to invest in certain businesses or industries, either directly through owning a business or indirectly through purchasing stocks or bonds....

Global site tag (gtag.js) - Google Analytics