简体   繁体   中英

Grails dateCreated field fails with “not-null property references a null or transient value”

I'm struggling to understand an error I'm getting with the Grails spring security UI plugin. Fundamentally the problem seems independent of that particular plugin, though.

The RegistrationCode domain class (see https://github.com/grails-plugins/grails-spring-security-ui/blob/master/grails-app/domain/grails/plugin/springsecurity/ui/RegistrationCode.groovy?source=cc ) has a dateCreated field, which uses the grails autoTimeStamp feature to populate it at creation. It seems to work 80% of the time, but I'm getting:

Exception Message: not-null property references a null or transient value: grails.plugin.springsecurity.ui.RegistrationCode.dateCreated 
Caused by: not-null property references a null or transient value: grails.plugin.springsecurity.ui.RegistrationCode.dateCreated 
Class: RegisterController 
At Line: [58]

This corresponds to the following code:

registrationCode = new RegistrationCode(username: user?.username)                                                                                                                               
registrationCode.save(flush: true)  

Again, the code seems to almost always work, but occasionally it seems to complain that the dateCreated field is null.

Any thoughts on why the autoTimeStamp periodically fails to fill in the dateCreated field?

I'm using Grails 2.2.4 and Mysql 5.5.27

It might be this bug: http://jira.grails.org/browse/GRAILS-9805 It's fixed in Grails 2.3.4.

What database and Grails version are you using?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM