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.
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
Peter Ledbrook
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Attachment | hasone-example.zip [ 50353 ] |
Graeme Rocher
made changes -
| Fix Version/s | 1.2.5 [ 16652 ] | |
| Fix Version/s | 1.3.5 [ 16651 ] |
Jeff Brown
made changes -
| Fix Version/s | 1.3.6 [ 16730 ] | |
| Fix Version/s | 1.3.5 [ 16651 ] |
Jeff Brown
made changes -
| Fix Version/s | 1.2.5 [ 16652 ] |
Jeff Brown
made changes -
| Assignee | Jeff Brown [ brownj ] |
Jeff Brown
made changes -
| Status | Open [ 1 ] | In Progress [ 3 ] |
Peter Ledbrook
made changes -
| Link | This issue is related to GRAILS-6538 [ GRAILS-6538 ] |
Jeff Brown
made changes -
| Fix Version/s | 1.3.6 [ 16730 ] | |
| Fix Version/s | 1.4-M1 [ 16812 ] |
Jeff Brown
made changes -
| Link | This issue duplicates GRAILS-5077 [ GRAILS-5077 ] |
Jeff Brown
made changes -
| Fix Version/s | 1.4-M1 [ 16812 ] | |
| Status | In Progress [ 3 ] | Closed [ 6 ] |
| Resolution | Won't Fix [ 2 ] |
Contegix Support
made changes -
| Project Import | Thu Mar 24 21:22:24 CDT 2011 [ 1301019744151 ] |
Burt Beckwith
made changes -
| Workflow | jira [ 34476 ] | Grails [ 46686 ] |
Burt Beckwith
made changes -
| Workflow | Grails [ 46686 ] | Copy of Grails [ 54143 ] |
Burt Beckwith
made changes -
| Workflow | Copy of Grails [ 54143 ] | Grails [ 61553 ] |
Burt Beckwith
made changes -
| Workflow | Grails [ 61553 ] | Grails2 [ 69133 ] |
Burt Beckwith
made changes -
| Workflow | Grails2 [ 69133 ] | jira [ 76778 ] |
Burt Beckwith
made changes -
| Workflow | jira [ 76778 ] | Grails2 [ 85342 ] |
Peter Ledbrook
made changes -
| Workflow | Grails2 [ 85342 ] | jira [ 93746 ] |
Peter Ledbrook
made changes -
| Workflow | jira [ 93746 ] | Grails2 [ 101908 ] |
Attaching an example project. Run the Grails console and then execute
new BootStrap().init()followed by
Author.list().each { a -> println a.name }Even though the above code doesn't use the location at all, you'll see in the console output that the locations for each author are loaded up front.