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

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2012 the original author or authors.
* Copyright 2011-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,6 +42,7 @@ import org.springframework.data.util.TypeInformation;
* Unit test for {@link AbstractMappingContext}.
*
* @author Oliver Gierke
* @author Thomas Darimont
*/
public class AbstractMappingContextUnitTests {
@@ -213,6 +214,16 @@ public class AbstractMappingContextUnitTests {
}
}
/**
* @see DATACMNS-447
*/
@Test
public void shouldReturnNullForSimpleTypesIfInStrictIsEnabled() {
context.setStrict(true);
assertThat(context.getPersistentEntity(Integer.class), is(nullValue()));
}
class Person {
String name;
}