当<class>元素或者<set>元素的lazy属性为true时,load() or get() or find()加载这些对象时,Hibernate不会马上产生任何select语句,只是产生一个Obj代理类实例,只有在session没有关闭的情况下运行Obj.getXxx()时才会执行select语句从数据库加载对象,如果没有运行任何Obj.getXxx()方法,而session已经关闭,Obj已成游离状态,此时再运行Obj.getXxx()方法,Hibernate就会抛出"Could not initialize proxy - the owning Session was closeed"的异常,是说Obj代理类实例无法被初始化。然而想在Session关闭之前不调用Obj.getXxx()方法而关闭Session之后又要用,此时只要在Session关闭之前调用Hibernate.initialize(Obj)或者Hibernate.initialize(Obj.getXxx())即可,net.sf.hibernate.Hibernate类的initialize()静态方法用于在Session范围内显示初始化代理类实例。
分享到:
相关推荐
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:225) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService...
NULL 博文链接:https://fkshl.iteye.com/blog/1178391
Ajax-jquery.initialize.zip,用于动态创建元素初始化的jquery插件(几年前很好,在2019年 考虑react或其他东西而不是jquery),ajax代表异步javascript和xml。它是多种web技术的集合,包括html、css、json、xml和...
解决org.hibernate.LazyInitializationException: could not initialize proxy - no Session...
jquery.initialize 1.4.0 1.4.0 之前的最新更新:添加了子元素数据绑定。 最新更新至 1.3.0:数据属性、模板属性和字符串模板替换。 一个简单的 jQuery 元素初始值设定项上下文插件。 该插件使元素初始化并将定义...
延迟加载类Lazy的使用示例。
初始化数组,对于在VC++编译环境下,该代码是非常有帮助的,可以让读者快速学习数组的应用。
\\.\Global\vmx86虚拟机启动过程中,报这种错误,然后启动不了。 本文档可以很好的解决这个问题。
import org.hibernate.HibernateException; import org.hibernate.Session; import org.hibernate.cfg.Configuration; /** * Configures and provides access to Hibernate sessions, tied to the * current ...
sexylightbox插件是lightbox繁衍而来,但它比lightbox更性感、更轻。演示地址:http://www.jq22.com/jquery-info535
NULL 博文链接:https://smartgwt.iteye.com/blog/1252268
XP系统在回放LoadRunner11录制脚本时提示“Vuser failed to initialize extension LrXml.dll”的解决方法
c# winform webkit C# 调用webkit
你只需要在 Application 里面调用Logcat.initialize一次即可完成初始化 //初始化Logcat Logcat.initialize(this); 配置更多信息 Builder builder = Logcat.newBuilder(); builder.logSavePath(StorageUtils....
这个版本可以支持jdk1.4及以上环境。 其他版本: ... SmartUpload 上传组件(中文终极解决版,包括中文文件名上传后乱码,中文参数,下载) 经过呕心沥血的一天一夜,终于搞定SmartUpload组件的所有中文问题,为大家去除...
initialize some custom attributes —— this step is not necessary, if you don't do it, it will use the default settings. TEmptyView.init(TViewUtil.EmptyViewBuilder.getInstance(context) .setShowText...
[!... Restring 1.0 ...Initialize Restring in your Application class: Restring.init(context); or if you want more configurations: Restring.init(context, new RestringConfig.Builder() .persist(tru
Grafana源码编译–Windows 准备工作 1、系统:Windows 2、软件: (1)GO:尽量使用跟... (2)Git:版本没有要求,用于从github中clone源码到本地,用法如下: # 进入某个文件夹 ...# clone源码到该文件夹下 git cl
Initialize Contacts Library public class MyApplication extends Application { @Override public void onCreate() { super.onCreate(); Contacts.initialize(this); } Get All Contacts List contacts = ...
We recommend adding the following line of code to your project source before the initialize which uses metal graphics and is faster to paint. begin FMX.Types.GlobalUseMetal := True; // add ...