From 8e59b18931e0dd2706ba8a72ddec31506aa83670 Mon Sep 17 00:00:00 2001 From: Peter-Josef Meisch Date: Wed, 2 Dec 2020 21:00:23 +0100 Subject: [PATCH] DATAES-989 - Improve deprecation warning for id properties without annotation. Original PR: #563 --- .../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.Logger; 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 class SimpleElasticsearchPersistentProperty extends // 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);