DATAES-989 - Improve deprecation warning for id properties without annotation.

Original PR: #563
This commit is contained in:
Peter-Josef Meisch 2020-12-02 21:00:23 +01:00 committed by GitHub
parent c66443ab5a
commit 8e59b18931
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);