Reputation: 203
I'm using spring-data to Integrate our application with Mongodb. In one of the use-cases, I invoke
MongoOperation.updateMulti(query, set.., Lead.class)
method to update a set of documents in our mongo collection. I also have a Listener bean registered that extends AbstractMongoEventListener to listen to events on this particular Collection(Lead) as follows
public class LeadListener extends AbstractMongoEventListener<Lead> {
@Override
public void onBeforeSave(Lead p, com.mongodb.DBObject dbo) {
//do something
}
@Override
public void onBeforeConvert(Lead p) {
//do something
}
}
I observed that none of these methods get fired when mongoOperation.updateMulti is executed, but they get called when mongoOperation.save(lead) is executed.
What is the equivalent listener method that I can use for this updateMulti/update operation.
Upvotes: 2
Views: 2692
Reputation: 3652
If you take a look into the source code, updateMulti calls the doUpdate method, which does not contain any triggers of listeners maybeEmitEvent(...).
Compared to the doRemove-Method, which calls events on remove.
It seems there is a slightly little inconsistency.
Upvotes: 1