Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column 'date_created' cannot be null #192

Open
abrahaj opened this issue Aug 16, 2019 · 3 comments
Open

Column 'date_created' cannot be null #192

abrahaj opened this issue Aug 16, 2019 · 3 comments

Comments

@abrahaj
Copy link

abrahaj commented Aug 16, 2019

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```
@abrahaj
Copy link
Author

abrahaj commented Aug 16, 2019

Same for newer versions of mysql-connector (tested with mysql-connector-java', version: '8.0.17')

@robertoschwald
Copy link
Contributor

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

@davidsonnabend
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants