DATACMNS-447 - Soften too strict strickt-check in MappingContext.

Previously we directly threw a MappingException in MappingContext.getPersistentEntity(TypeInformation) when the MappingContext was in strict mode and we were given a TypeInformation for which we didn't have a PersistentEntity already.

We now first check whether we should actually create a PersistentEntity for the given TypeInformation if no PersistentEntity is available, before throwing a  MappingException - if we should not then we simply return null (e.g. for simple types like Integer or Double).

Original pull requests: #66, #71.
This commit is contained in:
Michael Hunger
2014-02-23 02:01:09 +01:00
committed by Oliver Gierke
parent ae03feab42
commit b5727d4bf2
2 changed files with 18 additions and 5 deletions

View File

@@ -61,6 +61,8 @@ import org.springframework.util.ReflectionUtils.FieldFilter;
* @param P the concrete {@link PersistentProperty} type the {@link MappingContext} implementation creates
* @author Jon Brisbin
* @author Oliver Gierke
* @author Michael Hunger
* @author Thomas Darimont
*/
public abstract class AbstractMappingContext<E extends MutablePersistentEntity<?, P>, P extends PersistentProperty<P>>
implements MappingContext<E, P>, ApplicationEventPublisherAware, InitializingBean {
@@ -168,14 +170,14 @@ public abstract class AbstractMappingContext<E extends MutablePersistentEntity<?
read.unlock();
}
if (strict) {
throw new MappingException("Unknown persistent entity " + type);
}
if (!shouldCreatePersistentEntityFor(type)) {
return null;
}
if (strict) {
throw new MappingException("Unknown persistent entity " + type);
}
return addPersistentEntity(type);
}