|
Hey,
I have this domain class: class Report { Date createdAt String environment String reportName static constraints = { environment(blank: false, nullable: false) reportName(blank: false, nullable: false) } def beforeInsert = { createdAt = new Date() } } When I create a new object and call the save() method I get a validation error for the createdAt field. Does this mean beforeInsert is not called when saving a new object? Thanks Steven --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
|
validation is executed before save is called on the session, so it
never gets that far Cheers On 10/29/07, Steven Devijver <[hidden email]> wrote: > Hey, > > I have this domain class: > > class Report { > Date createdAt > String environment > String reportName > > static constraints = { > environment(blank: false, nullable: false) > reportName(blank: false, nullable: false) > } > > def beforeInsert = { > createdAt = new Date() > } > } > > When I create a new object and call the save() method I get a > validation error for the createdAt field. > > Does this mean beforeInsert is not called when saving a new object? > > Thanks > > Steven > > --------------------------------------------------------------------- > To unsubscribe from this list please visit: > > http://xircles.codehaus.org/manage_email > > -- Graeme Rocher Grails Project Lead http://grails.org --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
|
Hey Graeme,
The two other fields are properly filled in, I don't get validation errors for them. Do you mean that the validation step also checks the createdAt field? Thanks Steven On 10/29/07, Graeme Rocher <[hidden email]> wrote: > validation is executed before save is called on the session, so it > never gets that far > > Cheers > > On 10/29/07, Steven Devijver <[hidden email]> wrote: > > Hey, > > > > I have this domain class: > > > > class Report { > > Date createdAt > > String environment > > String reportName > > > > static constraints = { > > environment(blank: false, nullable: false) > > reportName(blank: false, nullable: false) > > } > > > > def beforeInsert = { > > createdAt = new Date() > > } > > } > > > > When I create a new object and call the save() method I get a > > validation error for the createdAt field. > > > > Does this mean beforeInsert is not called when saving a new object? > > > > Thanks > > > > Steven > > > > --------------------------------------------------------------------- > > To unsubscribe from this list please visit: > > > > http://xircles.codehaus.org/manage_email > > > > > > > -- > Graeme Rocher > Grails Project Lead > http://grails.org > > --------------------------------------------------------------------- > To unsubscribe from this list please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
|
On 10/29/07, Steven Devijver <[hidden email]> wrote:
> Hey Graeme, > > The two other fields are properly filled in, I don't get validation > errors for them. > > Do you mean that the validation step also checks the createdAt field? Yes, all fields are required by default Cheers > > Thanks > > Steven > > > > On 10/29/07, Graeme Rocher <[hidden email]> wrote: > > validation is executed before save is called on the session, so it > > never gets that far > > > > Cheers > > > > On 10/29/07, Steven Devijver <[hidden email]> wrote: > > > Hey, > > > > > > I have this domain class: > > > > > > class Report { > > > Date createdAt > > > String environment > > > String reportName > > > > > > static constraints = { > > > environment(blank: false, nullable: false) > > > reportName(blank: false, nullable: false) > > > } > > > > > > def beforeInsert = { > > > createdAt = new Date() > > > } > > > } > > > > > > When I create a new object and call the save() method I get a > > > validation error for the createdAt field. > > > > > > Does this mean beforeInsert is not called when saving a new object? > > > > > > Thanks > > > > > > Steven > > > > > > --------------------------------------------------------------------- > > > To unsubscribe from this list please visit: > > > > > > http://xircles.codehaus.org/manage_email > > > > > > > > > > > > -- > > Graeme Rocher > > Grails Project Lead > > http://grails.org > > > > --------------------------------------------------------------------- > > To unsubscribe from this list please visit: > > > > http://xircles.codehaus.org/manage_email > > > > > > --------------------------------------------------------------------- > To unsubscribe from this list please visit: > > http://xircles.codehaus.org/manage_email > > -- Graeme Rocher Grails Project Lead http://grails.org --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email |
| Powered by Nabble | Edit this page |
