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

lastUpdatedBy is not getting updated #182

Open
luke10 opened this issue Feb 24, 2019 · 6 comments
Open

lastUpdatedBy is not getting updated #182

luke10 opened this issue Feb 24, 2019 · 6 comments

Comments

@luke10
Copy link

luke10 commented Feb 24, 2019

Version: org.grails.plugins:audit-logging:3.0.3

I am new to this plugin, but have noticed a fairly critical issue. The last_updated_by column is not being updated when entities are updated. However, it is being set when the entity is first created (along with created_by)

Could this be a bug in the new version?

I'm not sure what the expected behaviour is, but I would expect:

  • On insert, lastUpdatedBy should be left as NULL
  • On update, lastUpdatedBy should be updated to the current authenticated user
@robertoschwald
Copy link
Contributor

What's your plugin config?

@luke10
Copy link
Author

luke10 commented Feb 25, 2019

grails:
    plugin:
        auditLog:
            auditDomainClassName: 'my.package.AuditTrail'
            excluded: ['createdBy','dateCreated','lastUpdatedBy','lastUpdated','version']

@longwa
Copy link
Contributor

longwa commented Feb 27, 2019

Are you using the Stampable trait on the entities?

@tekells-usgs
Copy link

I'm experiencing the same problem using version 3.0.1 (with Hibernate 5.1.16.Final) and the Stampable trait. I'm not trying to make lastUpdatedBy nullable like OP and initial value is set to match createdBy as expected. But changes to lastUpdatedBy afterwards are not saved to the database, whereas changes to other fields including lastUpdated are.

I can see that StampListener.handleUpdate is called after calling save(flush:true) and the value in the domain object is updated within the session of the one request. However, it's not saved to the database and subsequent requests show the unchanged value of lastUpdatedBy while all other changes to the domain including lastUpdated were persisted.

@MaxMoto1702
Copy link

MaxMoto1702 commented Apr 2, 2019

A similar problem occurs if you independently implement the abstract class AbstractPersistenceEventListener.
Within one thread, the changes applied in the implementation of the AbstractPersistenceEventListener class are available, and there are no changes in the other thread.

Example: https://github.com/MaxMoto1702/grails-AbstractPersistenceEventListener
and
grails-data-mapping/issues/1237

@zhangjiayu139
Copy link

@tekells-usgs How did you finally deal with this problem? I had the same problem,thanks

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

6 participants