spring-projects / spring-data-mongodb

Provides support to increase developer productivity in Java when using MongoDB. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
https://spring.io/projects/spring-data-mongodb/
Apache License 2.0
1.59k stars 1.07k forks source link

update* and findAndModify methods do not update audit fields. [DATAMONGO-869] #1797

Open spring-projects-issues opened 10 years ago

spring-projects-issues commented 10 years ago

Poorna Subhash opened DATAMONGO-869 and commented

DATAMONGO-811 addressed the update of @Version field.

But both update* and findAndModify methods lack in updating audit fields @CreatedBy, @LastModifiedBy, @CreatedDate, @LastModifiedDate .

Currently I am using workaround by writing aspects on MongoTemplate methods. Explained here http://poornasubhash.blogspot.in/2013/06/spring-mongodb-auditing-and-extensions.html.

It would be nice if this is included as part of framework.


Issue Links:

3 votes, 7 watchers

spring-projects-issues commented 10 years ago

Martin Baumgartner commented

The problem: MongoTemplate's doFindAndUpdate(..) and doUpdate(..) don't have listeners yet.

spring-projects-issues commented 6 years ago

Arulraj V commented

Any update on this...?

spring-projects-issues commented 4 years ago

shollander commented

This ticket is over five years old and still hasn't been fixed! Please fix, thanks!

spring-projects-issues commented 4 years ago

Mark Paluch commented

Auditing is applied only when working with entities directly via IsNewAwareAuditingHandler and not for query-based/bulk updates. Query-based updates require an association to an entity type, updates using just a collection name cannot participate in auditing updates

PedroEsnaola commented 2 years ago

My Auditing fields aren't setted even if entity class is passed on method

image image the updatedAt is setted during document creation, because i call the ReactiveMongoReposiroty method save() but when using reactive mongo template updateFirst or findAndModify with entity class, it doesn't work properly

Spring Boot Version 2.2.6.RELEASE Spring data mongodb reactive Version: 2.2.6.RELEASE

kubawell commented 2 years ago

this bug is fixed now ?

mahdibohloul commented 2 years ago

Any update about this issue?

kliarist commented 1 year ago

any news on this ?

ajax-semenov-y commented 1 year ago

any updates?

Leon-Shaw commented 1 year ago

any news?

MirAbgarAbrahamyan commented 1 year ago

Is this going to be fixed? It is very uncomfortable without this feature.

PixelBumper commented 1 year ago

I would love to help fixing this. As far as I have understood some callbacks are missing. Am I on the right track when looking at maybeCallBeforeConvert&maybeCallBeforeSave?

hockyy commented 1 year ago

up

jmuniyappan commented 10 months ago

any update please ?

jonymusky commented 9 months ago

up

Liveitabhi14 commented 5 months ago

any updates ?

ajax-siukhin-a commented 1 month ago

up

grassehh commented 1 week ago

Mark Paluch commented

Auditing is applied only when working with entities directly via IsNewAwareAuditingHandler and not for query-based/bulk updates. Query-based updates require an association to an entity type, updates using just a collection name cannot participate in auditing updates

So, what is the workaround ?? In my project, we benefit from the atomicity of the findAndModify operation because converter is not used when inserting a new document.