DATACMNS-1547 - Properly remove partially populated PersistentEntity instances from cache.

We now remove partially populated PersistentEntity instances from the cache held in AbstractMappingContext as the creation could fail for other RuntimeExceptions other than a MappingException and we wouldn't want to keep the instances around in any case.

Slight refactorings in the unit tests so that we can easily create MappingContext instances that reject certain types with certain exceptions.
This commit is contained in:
Oliver Drotbohm
2019-08-30 12:11:55 +02:00
parent 3e41d932dd
commit c42f5efe01
2 changed files with 78 additions and 24 deletions

View File

@@ -380,7 +380,7 @@ public abstract class AbstractMappingContext<E extends MutablePersistentEntity<?
entity.setPersistentPropertyAccessorFactory(persistentPropertyAccessorFactory);
}
} catch (MappingException e) {
} catch (RuntimeException e) {
persistentEntities.remove(typeInformation);
throw e;
}