Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: 2.0-M1
-
Fix Version/s: 2.0-M2
-
Component/s: Persistence
-
Labels:None
-
Environment:Mac OS X 10.7
Description
I've been preferring to use the constructor of my domain objects to set default values for properties, but this stopped working with Grails 2.0. For instance with the following constructor, new User() returns an object without those fields set at all - they are all null.
User() {
role = Role.Diner
enabled = true
cashBalance = 0
}
If I println this.dump() within the constructor and do the same for the object returned from new User(), they have different object ids, so something funny is going on - i.e. my constructor is definitely executed, but it's as if a second object is then constructed (without my constructor called) which is the one actually returned.
I can workaround this by directly assigning default values to the fields at the point of definition rather than in the constructor, but I believe this is a bug that should be fixed.
Issue Links
- relates to
-
GRAILS-8324
Domain object constructor ignored when creating new instance with arguments
-
Activity
- All
- Comments
- Work Log
- History
- Activity
- Git Commits