1.设置里 lazy = "false"
会导致 org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
"org.hibernate.LazyInitializationException: could not initialize proxy"延迟抓取出的错,hb3对many-to-one的默认处理是lazy = "proxy",把所有many-to-one,one-to-one都加上lazy="false"...
原因:hibernate3 many-to-one的默认选项是 lazy = "proxy"
解决方法:<many-to-one> & <set> 中设置 lazy="false"
2.说下解决方案~
在类名上@Proxy(lazy = false)注释~
然后在One的一方加入抓取模式注释 fetch = FetchType.EAGER~
3.Hibernate3延迟加载机制
首先说明Hibernate3延迟加载只多其中的load,get,find一些内值方法有用,对hql等写sql的无效。在Hibernate中提供了对实体对象的延迟加载以及对集合的延迟加载,另外在Hibernate3中还提供了对属性的延迟加载。
(1)实体对象的延迟加载
@OneToMany(mappedBy="role", fetch=FetchType.LAZY)
//mappedBy:定义双向关联中的从属类。使用在One一方,值为One方类名表示Many的从属类。
// // mappedBy="school"就相当于inverse=true,(mappedBy指定的是不需要维护关系的一端)
@OrderBy("id desc")
public Set<Staff> getStaffs() {
return staffs;
}
http://blog.csdn.net/it_man/archive/2009/08/02/4402317.aspx
分享到:
相关推荐
org.apache.poi:poi:4.1.2 org.apache.poi:poi-ooxml:4.1.2 org.apache.poi:poi-ooxml-schemas:4.1.2 org.apache.xmlbeans:xmlbeans:3.1.0 com.github.virtuald:curvesapi:1.06 com.zaxxer:SparseBitSet:1.2 commons...
当你尝试在Controller层或者视图层访问懒加载的属性时,如果Session已经关闭("no Session..."错误),就会抛出`org.hibernate.LazyInitializationException`。这是因为懒加载的代理对象需要Session来执行数据库查询...
标题 "Could not initialize class net.sf.jasperreports.engine.util.JRStyledTextParser" 提示了一个Java运行时错误,这通常意味着在尝试加载或初始化`JRStyledTextParser`类时遇到了问题。`JRStyledTextParser`是...
Caused by: org.hibernate.HibernateException: Could not instantiate connection provider [org.hibernate.connection.C3P0ConnectionProvider] at org.hibernate.engine.jdbc.connections.internal....
java.lang.NoClassDefFoundError: Could not initialize class org.apache.derby.jdbc.AutoloadedDriver40 导致的原因: 在azkaban的server和executor中缺少一个叫derby.jar的包
错误表现:在Session关闭后尝试访问懒加载属性,抛出“org.hibernate.LazyInitializationException: could not initialize proxy - no Session”异常。 解决方案:理解并合理使用Open Session in View(OSIV)模式...
<groupId>org.bytedeco <artifactId>javacpp <version>1.5.6 <groupId>org.bytedeco <artifactId>ffmpeg-platform <version>4.4-1.5.6 ``` 接下来,我们需要加载FFmpeg库。在32位Linux系统中,这意味着将...
7.注册如果发送邮件激活的方式出错(返回页面错误org.hibernate.LazyInitializationException: could not initialize proxy - no Session) 8.禁止用户后不允许登录、发帖、回帖等 9.后台会员搜索中文名搜索乱码 ...
jasperreport 用maven打包后找不到字体解决方案 net.sf.jasperreports.engine.JRRuntimeException: Could not load the following font
Could not initialize proxy - the owning Session was closed 这是Hibernate懒加载机制中的常见异常,当尝试访问一个已被关闭的Session中的懒加载属性时触发。例如,如果Session在使用`setFetchMode(FetchMode....
在使用PL/SQL Developer 12连接Oracle数据库时,可能会遇到“Could not initialize oci.dll”这样的错误提示。这个错误通常表明系统无法找到或正确加载Oracle客户端的oci.dll库文件,这是Oracle Instant Client的一...
ERROR org.apache.hadoop.mapred.TaskTracker: Can not start task tracker because java.io.IOException: Failed to set permissions of path: \tmp\hadoop-admin \mapred\local\ttprivate to 0700 at org.apache...
解决hbase client在windows环境下报Could not initialize class org.fusesource.jansi.internal.Kernel32的问题,把jar包放入hbase client的lib包下,重新运行hbase.cmd shell即可
Derby UI Plugin 1.1.1 是一个专门为Java开发者设计的用户界面插件,它在Java学习过程中能提供极大的便利。这个插件版本号为1.1.1,暗示了它可能包含了一些修复和改进,以提升用户体验和兼容性。...
Could not initialize "D:\app\Happy\product\11.2.0\dbhome_1\bin\oci.dll" Make sure you have the 32 bits Oracle Client installed. OracleHomeKey: OracleHomeDir: D:\app\Happy\product\11.2.0\dbhome_1 ...
/usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/pathname.rb:422:in `open': No such file or directory @ dir_initialize – /Users/David/.cocoapods/repos (Errno::ENOENT) from /usr/local/rvm/rubies/ruby-...
在这个特定的场景中,异常堆栈跟踪显示了 `Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections.Transformer`,这表明系统无法找到 `org.apache.commons.collections.Transformer` 类。...
java安装路径Java\jre\lib\security下替换这两个架包,即可解决 java.security.cert.CertificateException: Unable to initialize, java.io.IOException: Short read of DER length
// When building OkHttpClient, the OkHttpClient.Builder() is passed to the with() method to initialize the configuration OkHttpClient = RetrofitUrlManager.getInstance().with(new OkHttpClient.Builder...
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader). log4j:WARN Please initialize the log4j system properly. 2009-8-29 14:02:12 org.apache.catalina.core....