1

I am using Spring data Mongodb v1.6.2 and Spring 4.2.1. Today I noticed that @Indexed annotation on my entities did not trigger an index creation.

The entity is annotated with org.springframework.data.mongodb.core.mapping.Document and theorg.springframework.data.mongodb.core.mapping.Document is used.

@Document
public class Entity {
 @Indexed(unique= true)
 private String name;
}

1 Answer 1

2

After some investigation it appeared that MongoPersistentEntityIndexCreator did not receive the MappingContextEvent. Spring 4.2 altered the way generics are handled for ApplicationEvents.

Spring Data MongoDB fixed this in the following commit: https://github.com/spring-projects/spring-data-mongodb/commit/2a27eb74044d6480b228a216c1f93b2b0488c59a The issue tracker can be found here: https://jira.spring.io/browse/DATAMONGO-1224 This was fixed in all version so upgrading to 1.6.3 fixed the issue.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.