From 647b85548973df33e3c6c2746ce6a621595ca07b Mon Sep 17 00:00:00 2001 From: Peter-Josef Meisch Date: Wed, 2 Dec 2020 20:51:52 +0100 Subject: [PATCH] DATAES-989 - Improve deprecation warning for id properties without annotation. --- .../core/mapping/SimpleElasticsearchPersistentProperty.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentProperty.java b/src/main/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentProperty.java index 291734999..8f557f323 100644 --- a/src/main/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentProperty.java +++ b/src/main/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentProperty.java @@ -24,6 +24,7 @@ import org.slf4j.LoggerFactory; import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.DateFormat; +import org.springframework.data.elasticsearch.annotations.Document; import org.springframework.data.elasticsearch.annotations.Field; import org.springframework.data.elasticsearch.annotations.FieldType; import org.springframework.data.elasticsearch.annotations.GeoPointField; @@ -83,9 +84,9 @@ public SimpleElasticsearchPersistentProperty(Property property, // deprecated since 4.1 @Deprecated boolean isIdWithoutAnnotation = isId && !isAnnotationPresent(Id.class); - if (isIdWithoutAnnotation) { + if (isIdWithoutAnnotation && owner.isAnnotationPresent(Document.class)) { LOGGER.warn("Using the property name of '{}' to identify the id property is deprecated." - + " Please annotate the id property with '@Id'", getName()); + + " Please annotate the id property with '@Id'", owner.getName() + "." + getName()); } this.isScore = isAnnotationPresent(Score.class);