Hibernate 延迟加载类属性
来源:互联网 发布:淘宝造物节图片 编辑:程序博客网 时间:2024/05/17 17:16
Java web程序员偶尔会遇见此类问题:
could not initialize proxy - the owning Session was closed
1.
This error means that you're trying to access a lazily-loaded property or collection, but the hibernate session is closed. Lazy loading in Hibernate means that the object will not be populated (via a database query) until the property/collection is accessed in code. Hibernate accomplishes this by creating a dynamic proxy object that will hit the database only when you first use the object. In order for this to work, your object must be attached to an open Hibernate session throughout it's lifecycle. Check to see how you're managing your session. You may need to reattach objects to a new session if the session is being closed in some other place. 2.
attach
Purpose
Attaches a detached domain instance to the Hibernate session bound to the current thread
Examples
def b = Book.get(1)b.title = "Blah"b.save(flush:true)b.discard()
…if(!b.isAttached()) {b.attach()}
Description
Grails uses Hibernate which manages each persistent object in a persistence session. A new session is created per request and is closed at the end of the request. If an object is read from the session and placed into a web scope such as the HttpSession it is seen as detached, since the persistence session has been closed. You can use the attach() method to re-attach an existing persistent instance to the persistence session of the current request.
- Hibernate 延迟加载类属性
- Hibernate属性延迟加载
- Hibernate延迟加载之属性延迟加载
- Hibernate框架-----属性延迟加载和关系延迟加载(七)
- hibernate的级联、延迟加载、inverse属性
- Hibernate 集合属性的延迟加载
- Hibernate集合属性的延迟加载
- Hibernate 的延迟加载【lazy】属性
- Hibernate 延迟加载,lazy属性配置。以及org.hibernate.LazyInitializationException
- Hibernate延时加载---集合属性的延迟加载
- Hibernate3 实体属性的延迟加载——Hibernate深入浅出
- hibernate annotation方式实现属性级延迟加载
- Hibernate性能调优--集合属性的延迟加载
- Hibernate 5 & JPA 2.1 延迟加载大字段属性
- Spring+Hibernate延迟加载测试基类
- Hibernate中的延迟加载
- Hibernate延迟加载机制
- Hibernate延迟加载机制
- ANTLR 介绍
- D3D中可以变换的坐标系
- 十年
- 陪伴女儿成长:上海70男养女日记 2010年3月23日之规矩
- 安装了jdk1.6,但是用命令java -version查看版本的时候却是jdk1.4
- Hibernate 延迟加载类属性
- 编程实现木马的ActiveX启动和注入IE的启动方式
- 设计模式入门读书笔记(1):Iterator 一个一个数一遍
- 一个用来怀念,一个用来深爱
- Vb.Net程序设计:简单的查询条件组合(更新版)
- 追忆
- JfreeChart标题中文乱码的解决
- openldap之schema详解
- android 中Spinner与dialog的综合应用