Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Won't Fix
-
Affects Version/s: 1.3.3
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
Description
If I have the following domain model:
class Author {
String name
static hasOne = [ location: Location ]
}
class Location {
String city
}
then when I execute this code:
Author.list().each { a ->
println a.location.city
}
I find that the location instances are all loaded up front with separate SELECTs. In other words, they're loaded eagerly. Explicitly specifying the relationship as lazy: true has no effect.
Perhaps this behaviour is expected, but it seems strange to me.
-
Hide
- hasone-example.zip
- 28/Jul/10 3:12 AM
- 182 kB
- Peter Ledbrook
-
- hasone-example/.classpath 0.7 kB
- hasone-example/.project 0.5 kB
- hasone-example/.../org.codehaus.groovy.eclipse.preferences.prefs 0.1 kB
- hasone-example/application.properties 0.2 kB
- hasone-example/.../.DataSource.groovy.swp 12 kB
- hasone-example/.../BootStrap.groovy 0.5 kB
- hasone-example/.../BuildConfig.groovy 1 kB
- hasone-example/grails-app/.../Config.groovy 3 kB
- hasone-example/.../DataSource.groovy 0.8 kB
- hasone-example/.../resources.groovy 0.0 kB
- hasone-example/.../UrlMappings.groovy 0.2 kB
- hasone-example/grails-app/.../Author.groovy 0.2 kB
- hasone-example/.../Location.groovy 0.2 kB
- hasone-example/.../messages.properties 3 kB
- hasone-example/.../messages_da.properties 3 kB
- hasone-example/.../messages_de.properties 4 kB
- hasone-example/.../messages_es.properties 3 kB
- hasone-example/.../messages_fr.properties 2 kB
- hasone-example/.../messages_it.properties 2 kB
- hasone-example/.../messages_ja.properties 2 kB
- hasone-example/.../messages_nl.properties 3 kB
- hasone-example/.../messages_pt_BR.properties 3 kB
- hasone-example/.../messages_pt_PT.properties 3 kB
- hasone-example/.../messages_ru.properties 4 kB
- hasone-example/.../messages_th.properties 5 kB
- hasone-example/.../messages_zh_CN.properties 2 kB
- hasone-example/grails-app/.../error.gsp 2 kB
- hasone-example/grails-app/.../index.gsp 4 kB
- hasone-example/grails-app/.../main.gsp 0.7 kB
- hasone-example/web-app/css/main.css 5 kB
Issue Links
- duplicates
-
GRAILS-5077
hasOne mapping is by default eager and cannot be changed to lazy
-
- is related to
-
GRAILS-6538
Bidirectional 'one-to-one' mapping results in extra unnecessary query on relationship
-
Activity
- All
- Comments
- Work Log
- History
- Activity
- Git Commits