hibernate - 无法初始化代理 - 再次没有 session

标签 hibernate lazy-initialization

查看页面时我收到这些错误日志

ERROR [TP-Processor11] (LazyInitializationException.java:42) - could not initialize proxy - no Session
org.hibernate.LazyInitializationException: could not initialize proxy - no Session
    at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:132)
    at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:174)
    at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:190)
    at org.osmoz.contents.model.enm.ContentType_$$_javassist_71.getDefaultShortMode(ContentType_$$_javassist_71.java)
    at org.osmoz.contents.web.tapestry.components.EnmContentZone.getTemplate(EnmContentZone.java:67)
    at org.osmoz.contents.web.tapestry.base.AbstractRawContentZone.getContent(AbstractRawContentZone.java:67)
    at $PropertyConduit_1276091af82.get($PropertyConduit_1276091af82.java)
    at org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:58)
    at org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl$1.read(InternalComponentResourcesImpl.java:510)
    at org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl$1.read(InternalComponentResourcesImpl.java:496)
    at org.apache.tapestry5.corelib.components.OutputRaw._$read_parameter_value(OutputRaw.java)
    at org.apache.tapestry5.corelib.components.OutputRaw.beginRender(OutputRaw.java:43)
    at org.apache.tapestry5.corelib.components.OutputRaw.beginRender(OutputRaw.java)
    at

I know the problem is Session has been closed. But I really don't know why this error occur not so often that why I don't know the root cause is.

Enviroment:

Tapestry5, JPA, Hibernate 3.3.2.GA

I've set

<filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>

在 web.xml 中

最佳答案

使用 @Transactional在用 @Service 注释的层中的方法上( Spring 服务)。

关于hibernate - 无法初始化代理 - 再次没有 session ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2469700/

相关文章:

java - 删除 Hibernate 生成的延迟初始化代理的最安全方法是什么?

Swift:未初始化返回闭包的惰性变量

java - 更新多行 - Hibernate

java - 持久化多个实体及其关系(Cascade.All/ManyToMany)

java - hibernate 模式 : how to get the current audited table name?

java - 如何在 Java 中为成员 arraylist 变量实现惰性初始化?

java - Spring 3.0 lazy-init 不支持 DefaultMessageListenerContainer?

php - 增加数组中未设置变量/新键的好方法

Java 程序在 eclipse 中运行但不在命令提示符中

java - hibernate中的一对多映射: Referring two different properties to a single column