欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Grails - OpenSessionInView does not work with SiteMesh

程序员文章站 2022-05-23 15:54:12
...

grails 's bug description:

http://jira.codehaus.org/browse/GRAILS-2764

fetchMode

Purpose

Allows the configuration of an associations fetch strategy ('eager' or 'lazy')

Examples

class Author {
   String name
   static hasMany = [books:Book]
   static fetchMode = [books:'eager']
}
   

In this example the fetchMode static property specifies that the book association should be fetching eagerly

Description

By default associations in Grails are fetched lazily (each record is read from the database only when its first accessed from the collection). This makes sense for most cases, however in the case where you have a small number of records to fetch and/or are repeatedly required to load lazy associations (resulting in N+1) it makes sense to use eager fetching.

In the case of eager fetching and a one-to-many association, the instance as well as the association will be initialized when they are loaded (eagerly). However, caution should be observed when using eager fetching, being too eager can result in your entire database being loaded into memory!

相关标签: Grails