[Tapestry5] T5 + spring2.0 + hibernate3.2 LazyInitializationException

match927 2007-09-10
org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
可以通过设置lazy=false来避免
<class name="com.jeedev.hb.TSysuser" table="t_sysuser" lazy="false">

那如何用annotations来标注呢,多谢!
superaxis 2007-09-10
match927 写道
org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
请教了


通常是Open Session In View 的问题.

譬如,你用一个session load一个实体,此时改实体的属性并未完全load(lazy loading),然后关闭了session,在用另外一个地方调用改实体的属性,就会异常了。


Jun Tsai

ps:这个通常不是T的问题,应该算是Hibernate的问题。

match927 2007-09-10
那我用annotations方式,如何标住lazy是fasle
tapestry 2007-09-10
好像是
@Basic(fetch = FetchType.EAGER)
自己查一下hibernate-annnotation的文档
match927 2007-09-10
多谢各位,已找到是:
@Proxy(lazy=false)
@Entity
@Table(name = "T_BLOCKCONTENT")
public class ContentInfo implements Serializable


对应
<class name="com.jeedev.hb.ContentInfo " table="T_BLOCKCONTENT" lazy="false">
Global site tag (gtag.js) - Google Analytics