Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Duplicate
-
Affects Version/s: 2.0.1, 2.0.2
-
Fix Version/s: None
-
Component/s: Persistence
-
Labels:None
Description
I have a one to many association mapped as:
class Site {
static hasMany = [subItems:SubItem]
static fetchMode = [subItems: 'eager'] // not working in grails 2.0.1, 2.0.2
static mapping =
{ cache true subItems cache: true sort id: "desc" }}
class SubItem {
String mkey
String mvalue
static belongsTo = [site:Site]
static constraints =
{ mkey nullable: false, blank: false, maxSize: 255, matches: /[a-zA-Z0-9\.\-_]+/ mvalue shared:'longtext' }static mapping =
{ version false cache true }}
performing:
Site.findById(1)
correctly returns site #1, but if site #1 has more than one subItem... only the first subItem is returned (using the fetchMode designation). If you remove fetchMode the items are fetched lazily with a subsequent query and all values are found.
Seems due to the fact that the query being executed has a 'limit 1' at the end thereby returning only the first sub-item in the result-set rather than all sub items.
I think this is related to
GRAILS-8915.Same issue with n:m relation.