21
21
import java .io .Serializable ;
22
22
import java .lang .annotation .Annotation ;
23
23
import java .util .*;
24
+ import java .util .concurrent .ConcurrentHashMap ;
24
25
import java .util .stream .Collectors ;
25
26
26
27
import org .springframework .core .annotation .AnnotatedElementUtils ;
38
39
import org .springframework .util .Assert ;
39
40
import org .springframework .util .CollectionUtils ;
40
41
import org .springframework .util .ConcurrentReferenceHashMap ;
42
+ import org .springframework .util .ConcurrentReferenceHashMap .ReferenceType ;
41
43
import org .springframework .util .MultiValueMap ;
42
44
import org .springframework .util .StringUtils ;
43
45
@@ -105,8 +107,9 @@ public BasicPersistentEntity(TypeInformation<T> information, @Nullable Comparato
105
107
this .associations = comparator == null ? new HashSet <>() : new TreeSet <>(new AssociationComparator <>(comparator ));
106
108
107
109
this .propertyCache = new ConcurrentHashMap <>();
108
- this .annotationCache = new ConcurrentReferenceHashMap <>();
109
- this .propertyAnnotationCache = CollectionUtils .toMultiValueMap (new ConcurrentReferenceHashMap <>());
110
+ this .annotationCache = new ConcurrentReferenceHashMap <>(16 , ReferenceType .WEAK );
111
+ this .propertyAnnotationCache = CollectionUtils
112
+ .toMultiValueMap (new ConcurrentReferenceHashMap <>(16 , ReferenceType .WEAK ));
110
113
this .propertyAccessorFactory = BeanWrapperPropertyAccessorFactory .INSTANCE ;
111
114
this .typeAlias = Lazy .of (() -> getAliasFromAnnotation (getType ()));
112
115
this .isNewStrategy = Lazy .of (() -> Persistable .class .isAssignableFrom (information .getType ()) //
@@ -236,7 +239,7 @@ public void addPersistentProperty(P property) {
236
239
}
237
240
}
238
241
239
- /*
242
+ /*
240
243
* (non-Javadoc)
241
244
* @see org.springframework.data.mapping.model.MutablePersistentEntity#setEvaluationContextProvider(org.springframework.data.spel.EvaluationContextProvider)
242
245
*/
@@ -469,7 +472,7 @@ public IdentifierAccessor getIdentifierAccessor(Object bean) {
469
472
return hasIdProperty () ? new IdPropertyIdentifierAccessor (this , bean ) : new AbsentIdentifierAccessor (bean );
470
473
}
471
474
472
- /*
475
+ /*
473
476
* (non-Javadoc)
474
477
* @see org.springframework.data.mapping.PersistentEntity#isNew(java.lang.Object)
475
478
*/
@@ -481,7 +484,7 @@ public boolean isNew(Object bean) {
481
484
return isNewStrategy .get ().isNew (bean );
482
485
}
483
486
484
- /*
487
+ /*
485
488
* (non-Javadoc)
486
489
* @see org.springframework.data.mapping.PersistentEntity#isImmutable()
487
490
*/
@@ -516,7 +519,7 @@ protected EvaluationContext getEvaluationContext(Object rootObject) {
516
519
* Returns the default {@link IsNewStrategy} to be used. Will be a {@link PersistentEntityIsNewStrategy} by default.
517
520
* Note, that this strategy only gets used if the entity doesn't implement {@link Persistable} as this indicates the
518
521
* user wants to be in control over whether an entity is new or not.
519
- *
522
+ *
520
523
* @return
521
524
* @since 2.1
522
525
*/
@@ -526,7 +529,7 @@ protected IsNewStrategy getFallbackIsNewStrategy() {
526
529
527
530
/**
528
531
* Verifies the given bean type to no be {@literal null} and of the type of the current {@link PersistentEntity}.
529
- *
532
+ *
530
533
* @param bean must not be {@literal null}.
531
534
*/
532
535
private final void verifyBeanType (Object bean ) {
0 commit comments