Discussion:
Defaults for Domain Class Values (inconsistency)
KnownUnknown
2014-05-30 18:12:04 UTC
Permalink
Evaluated two ways to do this but neither produces the desired result
entirely. Both tactics are needed (I think?)

TACTIC 1

Class Contact {
String name
String address (for this example, all data in one field)
Integer timezoneDiff = 360
Boolean observesDST = true
}

Result: Create a record with name and address only and timezoneDiff and
observesDST will automatically have 360 and 1, respectively. BUT, if I look
at the table structure in mysql workbench the defaults are not indicated.

TACTIC 2

Replace the default settings above and instead use:

static mapping = {
timezoneDiff defaultValue: 360
observesDST defaultValue: true
}

This did NOT save the default values when a record was created with name and
address only. However, upon checking the table structure in mysql
workbench, these default values are indicated.

Granted, the appearance of these default values in the workbench structure
is far less important than the values being stored properly. But the
inconsistency between these two, where one works but falsely indicates in
workbench that it doesn't, while the other fails but falsely indicates in
workbench that it works, caused some confusion for a good little while.

Conclusion for now is to simply use both tactics in Contact.groovy. Can
anyone shed light on this, particularly to clarify and/or correct what I've
written so this post can be helpful to others?




--
View this message in context: http://grails.1312388.n4.nabble.com/Defaults-for-Domain-Class-Values-inconsistency-tp4657048.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Continue reading on narkive:
Loading...