|
22 | 22 |
|
23 | 23 | import org.slf4j.Logger;
|
24 | 24 | import org.slf4j.LoggerFactory;
|
25 |
| -import org.springframework.data.annotation.Id; |
26 | 25 | import org.springframework.data.elasticsearch.annotations.DateFormat;
|
27 |
| -import org.springframework.data.elasticsearch.annotations.Document; |
28 | 26 | import org.springframework.data.elasticsearch.annotations.Field;
|
29 | 27 | import org.springframework.data.elasticsearch.annotations.FieldType;
|
30 | 28 | import org.springframework.data.elasticsearch.annotations.GeoPointField;
|
@@ -80,24 +78,15 @@ public SimpleElasticsearchPersistentProperty(Property property,
|
80 | 78 |
|
81 | 79 | super(property, owner, simpleTypeHolder);
|
82 | 80 |
|
| 81 | + boolean isField = isAnnotationPresent(Field.class); |
83 | 82 | this.annotatedFieldName = getAnnotatedFieldName();
|
84 | 83 | this.fieldNamingStrategy = fieldNamingStrategy == null ? PropertyNameFieldNamingStrategy.INSTANCE
|
85 | 84 | : fieldNamingStrategy;
|
86 |
| - this.isId = super.isIdProperty() || SUPPORTED_ID_PROPERTY_NAMES.contains(getFieldName()); |
87 |
| - |
88 |
| - // deprecated since 4.1 |
89 |
| - @Deprecated |
90 |
| - boolean isIdWithoutAnnotation = isId && !isAnnotationPresent(Id.class); |
91 |
| - if (isIdWithoutAnnotation && owner.isAnnotationPresent(Document.class)) { |
92 |
| - LOGGER.warn("Using the property name of '{}' to identify the id property is deprecated." |
93 |
| - + " Please annotate the id property with '@Id'", owner.getName() + "." + getName()); |
94 |
| - } |
95 |
| - |
| 85 | + this.isId = super.isIdProperty() |
| 86 | + || (SUPPORTED_ID_PROPERTY_NAMES.contains(getFieldName()) && !hasExplicitFieldName()); |
96 | 87 | this.isParent = isAnnotationPresent(Parent.class);
|
97 | 88 | this.isSeqNoPrimaryTerm = SeqNoPrimaryTerm.class.isAssignableFrom(getRawType());
|
98 | 89 |
|
99 |
| - boolean isField = isAnnotationPresent(Field.class); |
100 |
| - |
101 | 90 | if (isVersionProperty() && !getType().equals(Long.class)) {
|
102 | 91 | throw new MappingException(String.format("Version property %s must be of type Long!", property.getName()));
|
103 | 92 | }
|
@@ -141,6 +130,10 @@ public boolean storeNullValue() {
|
141 | 130 | return storeNullValue;
|
142 | 131 | }
|
143 | 132 |
|
| 133 | + protected boolean hasExplicitFieldName() { |
| 134 | + return StringUtils.hasText(getAnnotatedFieldName()); |
| 135 | + } |
| 136 | + |
144 | 137 | /**
|
145 | 138 | * Initializes an {@link ElasticsearchPersistentPropertyConverter} if this property is annotated as a Field with type
|
146 | 139 | * {@link FieldType#Date}, has a {@link DateFormat} set and if the type of the property is one of the Java8 temporal
|
|
0 commit comments