Skip to content

deleteBy/removeBy repository methods don't set type information in Before/AfterDeleteEvent [DATAMONGO-978] #1903

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

Closed
spring-projects-issues opened this issue Jul 2, 2014 · 3 comments
Assignees
Labels
in: repository Repositories abstraction type: bug A general bug

Comments

@spring-projects-issues
Copy link

Faisal Feroz opened DATAMONGO-978 and commented

In AbstractMongoQuery.java the nested DeleteExecution class has the following method

private Object deleteAndConvertResult(Query query, MongoEntityMetadata<?> metadata) {

			if (method.isCollectionQuery()) {
				return operations.findAllAndRemove(query, metadata.getJavaType());
			}

			WriteResult writeResult = operations.remove(query, metadata.getCollectionName());
			return writeResult != null ? writeResult.getN() : 0L;
		}

Here the javatype is not passed to operations.remove method although there is an overloaded method of remove which accepts the type. The result ends up as having null in the type value inside the Before/AfterDeleteEvent and the result events are although fired but never end up handled in the respective Type's Event Handlers if any.

A simple fix would be to change it to:

WriteResult writeResult = operations.remove(query, metadata.getJavaType(), metadata.getCollectionName());

Affects: 1.5 GA (Dijkstra)

Referenced from: pull request #199

Backported to: 1.5.2 (Dijkstra SR2)

@spring-projects-issues
Copy link
Author

Faisal Feroz commented

this issue is related to the functionality provided under DATAMONGO-566

@spring-projects-issues
Copy link
Author

Christoph Strobl commented

Sorry for the inconvenience and thanks for the detailed report!

@spring-projects-issues
Copy link
Author

Thomas Darimont commented

Merged into master and back-ported in 1.5.x branch for Dijkstra SR2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: repository Repositories abstraction type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants