diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapping/BasicMongoPersistentEntity.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapping/BasicMongoPersistentEntity.java index 7c56c8c283..eb63c037e6 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapping/BasicMongoPersistentEntity.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapping/BasicMongoPersistentEntity.java @@ -26,6 +26,7 @@ import org.springframework.context.ApplicationContextAware; import org.springframework.context.expression.BeanFactoryAccessor; import org.springframework.context.expression.BeanFactoryResolver; +import org.springframework.core.annotation.AnnotationUtils; import org.springframework.data.annotation.Id; import org.springframework.data.mapping.Association; import org.springframework.data.mapping.AssociationHandler; @@ -77,7 +78,7 @@ public BasicMongoPersistentEntity(TypeInformation typeInformation) { Class rawType = typeInformation.getType(); String fallback = MongoCollectionUtils.getPreferredCollectionName(rawType); - Document document = rawType.getAnnotation(Document.class); + Document document = AnnotationUtils.findAnnotation(rawType, Document.class); this.expression = detectExpression(document); this.context = new StandardEvaluationContext(); @@ -96,6 +97,7 @@ public BasicMongoPersistentEntity(TypeInformation typeInformation) { * (non-Javadoc) * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext) */ + @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { context.addPropertyAccessor(new BeanFactoryAccessor()); @@ -107,6 +109,7 @@ public void setApplicationContext(ApplicationContext applicationContext) throws * (non-Javadoc) * @see org.springframework.data.mongodb.core.mapping.MongoPersistentEntity#getCollection() */ + @Override public String getCollection() { return expression == null ? collection : expression.getValue(context, String.class); } @@ -174,6 +177,7 @@ static enum MongoPersistentPropertyComparator implements Comparator properties = new HashMap(); + @Override public void doWithPersistentProperty(MongoPersistentProperty persistentProperty) { assertUniqueness(persistentProperty); } + @Override public void doWithAssociation(Association association) { assertUniqueness(association.getInverse()); } @@ -351,9 +357,9 @@ private static void assertPropertyType(MongoPersistentProperty persistentPropert } } - throw new MappingException( - String.format("Missmatching types for %s. Found %s expected one of %s.", persistentProperty.getField(), - persistentProperty.getActualType(), StringUtils.arrayToCommaDelimitedString(validMatches))); + throw new MappingException(String.format("Missmatching types for %s. Found %s expected one of %s.", + persistentProperty.getField(), persistentProperty.getActualType(), + StringUtils.arrayToCommaDelimitedString(validMatches))); } } }