`

org.hibernate.LazyInitializationException: failed to lazily initialize a collect

 
阅读更多

这个异常:org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: org.joshua.ss.entity.SysUsers.sysUsersRoleses, no session or session was closed

Exception in thread "main" org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: org.joshua.ss.entity.SysUsers.sysUsersRoleses, no session or session was closed
	at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:380)
	at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:372)
	at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:365)
	at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:108)
	at org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:186)



原因:在hibernate的映射关系中由于延迟加载,之前的操作使session已经关闭,所以加载set属性时无可用session
解决办法:在映射文件中设置set属性 lazy='false'

<set name="sysUsersRoleses" inverse="true" cascade="all" lazy="false">
            <key>
                <column name="USER_ID" length="32" />
            </key>
            <one-to-many class="org.joshua.ss.entity.SysUsersRoles" />
        </set>

 

分享到:
评论

相关推荐

    广东省深圳市文汇中学2015届九年级英语上学期第7周周末作业(答案不全) 牛津深圳版

    `lazily`:金鱼慵懒地(lazily)成群结队地在水面下游动。 - 15. `coats`:他们给前门刷了三层(coats)油漆。 2. **关键短语或词组**: - 1. `come along`:一起来,过来。 - 2. `a novel called…`:一本叫做...

    广东省广州市2018年中考英语学科模拟题十六20180709274

    3. 冠词:"a good worker",不定冠词a用于表示泛指,此处表示“一个好工人”。 4. 形容词与过去分词的区别:"Although surprised",形容词surprised用于表示人的感受。 5. 连词:"because he really needed help",...

    Packt.Mastering.Csharp.and.NET.Programming

    - **.NET as a Reaction to the Java World**: Microsoft’s response to Sun Microsystems’ Java platform, aiming to provide a robust framework for building and running applications. - **The Open Source...

    Android代码-Kodein-DI

    Kodein is a very simple and yet very useful dependency retrieval container. it is very easy to use and configure. Kodein works: On the JVM. On Android. On Javascript (both in the browser and on Node....

    ksadaful.github.io:个人网站

    10. **性能优化**:使用`requestAnimationFrame`进行动画更新,或者利用`Lazily Load Images`等策略提高网站加载速度,都是JavaScript性能优化的常见手段。 11. **错误处理**:为了确保网站的健壮性,开发者可能...

    2019_2020学年高中英语Unit4BodyLanguageperiod2WarmingUp&Reading2课件新人教版必

    - 完成句子练习可以帮助巩固词汇的应用,如:"The young man rose lazily and was not willing to greet us."(年轻人懒洋洋地起身,并不愿意向我们打招呼。),"This appointment was greeted with relief."(这个...

    Free Hex Control

    / specific area difficult, so I lazily redraw almost the whole control whenever / it needs. This results in the slowness (I suggest you can use the control in data / display, ^_^). In next version,...

    Redis的Scala客户端Scredis.zip

    // Subscribes to a Pub/Sub channel using the internal, lazily initialized SubscriberClient redis.subscriber.subscribe("My Channel") {  case message @ PubSubMessage.Message(channel, ...

    Git-2.21.0-64-bit.zip

    committed, the command line prompt script failed to notice the current status, which has been improved. * Many GIT_TEST_* environment variables control various aspects of how our tests are run, ...

    Pandas Cookbook 2017 pdf 2分

    Slicing rows lazily Getting ready How to do it... How it works... There's more... Slicing lexicographically Getting ready How to do it... How it works... There's more... 5. Boolean Indexing ...

    新概念英语第一册第109-110课PPT课件.pptx

    - 以辅音字母+y结尾的词,如"lazily",改y为i再加"-er/est",形成"lazier"和"laziest"。 - 以不发音的e结尾的形容词,如"large",直接加"-r/-st",得到"larger"和"largest"。 - 多音节和某些双音节词,如...

    ModalDB:为进行多模态数据研究而优化的数据库。 为斯坦福人工智能实验室的 Robo Brain 项目构建

    例如: In [1]: video_frame['subtitles'] # loads quickly from in-memory...In [2]: video_frame['image'] # loads lazily from disk能够定义数据对象的任意嵌套层次结构。 例如,“视频”可以具有关联的属性...

    第 2-6 课:使⽤ Spring Boot 和 Thymeleaf 演示上传⽂件1

    spring.servlet.multipart.resolve-lazily=false ``` 在实际应用中,为了处理文件上传,我们需要创建一个Controller,它会接收前端发送的文件。`MultipartFile`是Spring提供的接口,用于处理文件上传请求。以下是一...

    新概念英语第二册单元测试答案.doc

    2. **情态动词**:A部分中的情态动词如can(能),must(必须),may(可能),might(可能),could(能够)等展示了不同可能性和必要性的表达。在E部分中,针对这些情态动词的否定形式进行了提问和回答,帮助学生...

    安卓 image

    包括选择合适的图片格式(如WebP)、压缩图片大小、利用惰性加载(Lazily load images)等技术。 综上所述,"安卓 image"涉及了Android开发中的图像资源管理、菜单设计、全屏模式的实现以及图像的显示和处理等多个...

    svc.rar_Will

    在这样的上下文中,"lazily created"可能意味着某些对象或服务会在实际需要时才进行实例化,以优化性能和资源利用率。 3. **svc.c**: "svc"通常代表"Service",这可能是实现某种特定服务的代码,如网络服务、系统...

    springframework.5.0.12.RELEASE

    Exporting a lazily initialized bean (which implements SelfNaming and is annotated with ManagedResource annotation) gives IllegalStateException [SPR-17592] #22124 MockHttpServletRequest changes Accept-...

    react-lazily-render:延迟安装昂贵的组件,直到将占位符组件滚动到视图中为止

    npm install --save react-lazily-render 用法 () import React from 'react' ; import LazilyRender from 'react-lazily-render' ; ...lots of content... &lt; LazilyRender xss=removed&gt; } content = { ...

    2021届福建省高三英语三校联考试题答案.docx

    题目中给出的每篇文章后都有对应的答案,例如A篇21-23题答案为DDB,这表明学生需要通过阅读原文,理解文章内容,然后选择正确答案。 2. **七选五**:这种题型要求学生根据文章内容,从七个选项中选出五个最合适的...

    Android代码-clojure-jsr223

    lazily. Copyright (c) 2009 Armando Blancas. All rights reserved. The use and distribution terms for this software are covered by the Eclipse Public License 1.0 ...

Global site tag (gtag.js) - Google Analytics