File tree Expand file tree Collapse file tree 2 files changed +22
-9
lines changed
main/java/org/springframework/data/mapping/context
test/java/org/springframework/data/mapping/context Expand file tree Collapse file tree 2 files changed +22
-9
lines changed Original file line number Diff line number Diff line change @@ -178,12 +178,8 @@ public E getPersistentEntity(P persistentProperty) {
178
178
return null ;
179
179
}
180
180
181
- try {
182
- read .lock ();
183
- return persistentEntities .get (persistentProperty .getTypeInformation ());
184
- } finally {
185
- read .unlock ();
186
- }
181
+ TypeInformation <?> typeInfo = persistentProperty .getTypeInformation ();
182
+ return getPersistentEntity (typeInfo .getActualType ());
187
183
}
188
184
189
185
/*
Original file line number Diff line number Diff line change 21
21
import groovy .lang .MetaClass ;
22
22
23
23
import java .util .Collections ;
24
+ import java .util .List ;
24
25
25
26
import org .junit .Before ;
26
27
import org .junit .Test ;
@@ -144,7 +145,7 @@ public void doesNotCreatePersistentPropertyForGroovyMetaClass() {
144
145
}
145
146
146
147
/**
147
- * @see DATACMNS-???
148
+ * @see DATACMNS-332
148
149
*/
149
150
@ Test
150
151
public void usesMostConcreteProperty () {
@@ -154,6 +155,22 @@ public void usesMostConcreteProperty() {
154
155
assertThat (entity .getPersistentProperty ("foo" ).isIdProperty (), is (true ));
155
156
}
156
157
158
+ /**
159
+ * @see DATACMNS-345
160
+ */
161
+ @ Test
162
+ @ SuppressWarnings ("rawtypes" )
163
+ public void returnsEntityForComponentType () {
164
+
165
+ SampleMappingContext mappingContext = new SampleMappingContext ();
166
+ PersistentEntity <Object , SamplePersistentProperty > entity = mappingContext .getPersistentEntity (Sample .class );
167
+ SamplePersistentProperty property = entity .getPersistentProperty ("persons" );
168
+ PersistentEntity <Object , SamplePersistentProperty > propertyEntity = mappingContext .getPersistentEntity (property );
169
+
170
+ assertThat (propertyEntity , is (notNullValue ()));
171
+ assertThat (propertyEntity .getType (), is (equalTo ((Class ) Person .class )));
172
+ }
173
+
157
174
class Person {
158
175
String name ;
159
176
}
@@ -165,14 +182,14 @@ class Unsupported {
165
182
class Sample {
166
183
167
184
MetaClass metaClass ;
185
+ List <Person > persons ;
168
186
}
169
187
170
188
static class Base {
171
189
String foo ;
172
190
}
173
191
174
192
static class Extension extends Base {
175
- @ Id
176
- String foo ;
193
+ @ Id String foo ;
177
194
}
178
195
}
You can’t perform that action at this time.
0 commit comments