环境 spring+hibernate3+struts
今天又碰到错误
failed to lazily initialize a collection of role: no session or session was closed
试验了一下发现了几个解决方法:
1、是把对应一对多的那两个列lazy=true改为lazy=false即可
2、对于查询中如果用的是xxx.load(class,id)则改为xxx,get(class,id)
3在web.xml文件中加入
<filter>
<filter-name>hibernateFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
<init-param>
<param-name>singleSession</param-name>
<param-value>false</param-value>
</init-param>
<!--这个-- <init-param>一定要加不然很可能会报错:org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly' marker from transaction definition
>
</filter>
<filter-mapping>
<filter-name>hibernateFilter</filter-name>
<url-pattern>*.mmg</url-pattern>
</filter-mapping>
分享到:
相关推荐
2. **Hibernate的session问题**: "no session or session was closed"提示可能是因为在Hibernate配置文件中,外键的lazy属性设置为"true"。若需要立即加载关联对象,应将其改为"false"。 3. **Struts的checkbox使用...
- **技术难题**:实习生在项目开发过程中会遇到各种技术难题,例如数据库连接失败(`failedtolazilyinitializeacollection: nosession or session was closed`)等问题。 - **解决方案探索**:通过查阅文档、搜索...
session.setConfig("StrictHostKeyChecking", "no"); session.connect(); sftpChannel = (ChannelSftp) session.openChannel("sftp"); sftpChannel.connect(); sftpChannel.cd("/path/to/remote/directory");...
官方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.
Could not initialize proxy - the owning Session was closed 这是Hibernate懒加载机制中的常见异常,当尝试访问一个已被关闭的Session中的懒加载属性时触发。例如,如果Session在使用`setFetchMode(FetchMode....
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 ...
Exception in thread "main" org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed ``` - **日志记录**:为了更好地诊断问题,可以使用log4j等工具进行日志...
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...
在使用VirtualBox虚拟化软件时,可能会遇到“不能为虚拟电脑打开一个新任务”的错误,这通常是由于多种原因导致的。对于这个问题,我们需要深入理解VirtualBox的工作原理,并采取相应的解决方案来修复。...
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. **发送模式** - **异步发送**:通过添加`...