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 ;
@@ -83,16 +81,8 @@ public SimpleElasticsearchPersistentProperty(Property property,
83
81
this .annotatedFieldName = getAnnotatedFieldName ();
84
82
this .fieldNamingStrategy = fieldNamingStrategy == null ? PropertyNameFieldNamingStrategy .INSTANCE
85
83
: 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
-
84
+ this .isId = super .isIdProperty ()
85
+ || (SUPPORTED_ID_PROPERTY_NAMES .contains (getFieldName ()) && !hasExplicitFieldName ());
96
86
this .isParent = isAnnotationPresent (Parent .class );
97
87
this .isSeqNoPrimaryTerm = SeqNoPrimaryTerm .class .isAssignableFrom (getRawType ());
98
88
@@ -106,6 +96,7 @@ public SimpleElasticsearchPersistentProperty(Property property,
106
96
throw new MappingException (String .format ("Parent property %s must be of type String!" , property .getName ()));
107
97
}
108
98
99
+
109
100
if (isField && isAnnotationPresent (MultiField .class )) {
110
101
throw new MappingException ("@Field annotation must not be used on a @MultiField property." );
111
102
}
@@ -141,6 +132,10 @@ public boolean storeNullValue() {
141
132
return storeNullValue ;
142
133
}
143
134
135
+ protected boolean hasExplicitFieldName () {
136
+ return StringUtils .hasText (getAnnotatedFieldName ());
137
+ }
138
+
144
139
/**
145
140
* Initializes an {@link ElasticsearchPersistentPropertyConverter} if this property is annotated as a Field with type
146
141
* {@link FieldType#Date}, has a {@link DateFormat} set and if the type of the property is one of the Java8 temporal
0 commit comments