failed to lazily initialize a collection of role: com.ares.pojo.Member.prepaidlogsForOperateid, no session or session was closed 异常
在一个项目当中,以注解开发.当用户从login页面登录后跳转到main页面当中(Main页面把其它页面组织在一起),而在Main当中要验证用户是否登录过,也就是验证存在Session里的用户信息是不是还在.
当然在Action里写了一个验证方法,可是一执行此方法时出错下面的错,如下图:
网上搜了一下http://blog.sina.com.cn/s/blog_60f6320501011sm6.html大家可学习一下.
我也总结一下,避免自己下次再出错:
大家可以看到我上面的图当中:com.ares.pojo.Member这是我包面下面的实体,当我用注解时我是使用工具自动给我生成的实体,当然生成后的实体一对多的注解:
上图当中红色部份就是Hibernate的LAZY 也就是Hibernatelazy用来控制延迟加载和立即加载的.
多的不错了,我百度了一下还有这个LAZY的面试题,如地址:http://zhidao.baidu.com/question/89445445.html
好吧我的处理就是如下图:
相关推荐
Could not initialize proxy - the owning Session was closed 这是Hibernate懒加载机制中的常见异常,当尝试访问一个已被关闭的Session中的懒加载属性时触发。例如,如果Session在使用`setFetchMode(FetchMode....
session.setConfig("StrictHostKeyChecking", "no"); session.connect(); sftpChannel = (ChannelSftp) session.openChannel("sftp"); sftpChannel.connect(); sftpChannel.cd("/path/to/remote/directory");...
2. **Hibernate的session问题**: "no session or session was closed"提示可能是因为在Hibernate配置文件中,外键的lazy属性设置为"true"。若需要立即加载关联对象,应将其改为"false"。 3. **Struts的checkbox使用...
官方2013年5月2号更新的SecureCRT+SecureFX v... - Mac/Linux: If the toolbar was displayed, when SecureFX was closed and restarted, the application window was shorter that the previous time SecureFX ran.
- **技术难题**:实习生在项目开发过程中会遇到各种技术难题,例如数据库连接失败(`failedtolazilyinitializeacollection: nosession or session was closed`)等问题。 - **解决方案探索**:通过查阅文档、搜索...
Exception in thread "main" org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed ``` - **日志记录**:为了更好地诊断问题,可以使用log4j等工具进行日志...
To make use of either more or less strict isolation levels in applications, locking can be customized for an entire session by setting the isolation level of the session with the SET TRANSACTION ...
This specification was developed in response to a perceived need for a standardized programming inter-face to digitizing tablets, three dimensional position sensors, and other pointing devices by a ...
在使用VirtualBox虚拟化软件时,可能会遇到“不能为虚拟电脑打开一个新任务”的错误,这通常是由于多种原因导致的。对于这个问题,我们需要深入理解VirtualBox的工作原理,并采取相应的解决方案来修复。...
To reserve or commit memory and unintentionally not release it when it is no longer being used. A process can leak resources such as process memory, pool memory, user and GDI objects, handles, threads...
Fixed flash-of-white that could occur when the auto complete window is closed Disable scroll animation when animation_enabled is false in settings Files can now be renamed when only the case has ...
TClientDataSet does not order correctly on a TLargeIntField when used in an index or in the IndexFieldNames property (Quality Central 1050 & 2626) * TAggregateField returns an incorrect value after a ...
b) Since each user requires 1Mbps when transmitting, if two or fewer users transmit simultaneously, a maximum of 2Mbps will be required. Since the available bandwidth of the shared link is 2Mbps, ...
- **网络异常与"The Session is closed"错误**:为避免因网络问题导致的断开连接,可设置`maxReconnectDelay`,如`maxReconnectDelay=10000`,以控制最大重连间隔。 3. **发送模式** - **异步发送**:通过添加`...