Column 'date_created' cannot be null
Opened this issue · 3 comments
Seems there is an issue with logging due to a "Column 'date_created' cannot be null" and MySQL
Using:
grailsVersion=3.3.9
gormVersion=6.1.11.RELEASE
audit-logging:3.0.4
name: 'mysql-connector-java', version: '5.1.47'
into
audit_log
(persisted_object_id, property_name, date_created, last_updated, event_name, actor, new_value, class_name, old_value, persisted_object_version, uri)
values
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate:
insert
into
audit_log
(persisted_object_id, property_name, date_created, last_updated, event_name, actor, new_value, class_name, old_value, persisted_object_version, uri)
values
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
...
2019-08-16 10:54:50.502 TRACE --- [nio-8080-exec-3] o.h.type.descriptor.sql.BasicBinder : binding parameter [3] as [TIMESTAMP] - [null]
2019-08-16 10:54:50.502 TRACE --- [nio-8080-exec-3] o.h.type.descriptor.sql.BasicBinder : binding parameter [3] as [TIMESTAMP] - [null]
2019-08-16 10:54:50.502 TRACE --- [nio-8080-exec-3] o.h.type.descriptor.sql.BasicBinder : binding parameter [4] as [TIMESTAMP] - [null]
2019-08-16 10:54:50.502 TRACE --- [nio-8080-exec-3] o.h.type.descriptor.sql.BasicBinder : binding parameter [4] as [TIMESTAMP] - [null]
...
2019-08-16 10:54:50.523 ERROR --- [nio-8080-exec-3] o.h.engine.jdbc.spi.SqlExceptionHelper : Column 'date_created' cannot be null
2019-08-16 10:54:50.537 ERROR --- [nio-8080-exec-3] g.p.orm.auditable.AuditLogListener : Error creating audit log for event PostInsert and domain anyDomain : 3```
Same for newer versions of mysql-connector (tested with mysql-connector-java', version: '8.0.17')
How does your AuditTrail class look like?
Autotimestamp is normally on. There is a fallback in the listener to create the actual dateCreated.
See https://github.com/robertoschwald/grails-audit-logging-plugin/blob/master/plugin/src/main/groovy/grails/plugins/orm/auditable/AuditLogListener.groovy#L192
I have had the same problem with the default AuditTrail
class created by grails audit-quickstart
.
After removing autoTimestamp false
from mapping closure, everything works fine.