Grails 域类中的惰性列加载
我有一个像这样的域类:
class Document {
String mime;
String name;
byte[] content;
static mapping = {
content lazy:true;
}
}
并且我想启用对“内容”列的延迟加载,因为应用程序无需访问此列即可执行一些操作。
但是lazy:true选项不起作用...有什么想法或解决方法吗?
I have a domain class like this:
class Document {
String mime;
String name;
byte[] content;
static mapping = {
content lazy:true;
}
}
and I'd like to enable lazy loading to the "content" column, because the application does some stuff without the need of access to this column.
But the lazy:true option didn't work... any idea or workaround?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此处有一些关于使用 Hibernate 注释延迟加载特定内容的讨论柱子。
另一种可能性是将 Document 对象分成两部分。像这样:
由于这是一个关系,GORM 默认情况下会延迟加载 DocumentContent。
There is some discussion here about using Hibernate annotations to lazily load a specific column.
Another possibility is to break your Document object into two pieces. Something like this:
Since this is a relation, GORM will lazily load the DocumentContent by default.
应用程序执行某些操作是什么意思?你想建立什么?
供参考。急切加载和延迟加载通常与关系有关,grails 默认情况下启用延迟加载。例如“
在您的代码中没有关系。内容是文档的属性,因此延迟加载在这里不适用。
http://grails.org/doc/1.0.x/guide/5.%20Object%20Relational%20Mapping%20(GORM).html
What do you mean by the application does some stuff? and what are you trying to establish?
FYI. eager and lazy loading usually has to do with relations, grails by default has lazy loading enabled. e.g."
In your code there is no relation. content is a property of Document, hence lazy loading doesn't apply here.
http://grails.org/doc/1.0.x/guide/5.%20Object%20Relational%20Mapping%20(GORM).html