DATACMNS-1171 - Do not create PersistentEntity for unsupported Kotlin classes.
We now reject unsupported Kotlin classes from the MappingContext by default by not creating persistent entities. Original pull request: #245.
This commit is contained in:
committed by
Oliver Gierke
parent
d9d0d594e5
commit
cc0ab54c38
@@ -45,6 +45,7 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Thomas Darimont
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class AbstractMappingContextUnitTests {
|
||||
|
||||
@@ -210,6 +211,16 @@ public class AbstractMappingContextUnitTests {
|
||||
assertHasEntityFor(TreeMap.class, context, false);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1171
|
||||
public void shouldCreateEntityForKotlinDataClass() {
|
||||
assertThat(context.getPersistentEntity(SimpleDataClass.class)).isNotNull();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1171
|
||||
public void shouldNotCreateEntityForSyntheticKotlinClass() {
|
||||
assertThat(context.getPersistentEntity(TypeCreatingSyntheticClass.class)).isNotNull();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-695
|
||||
public void persistentPropertyPathTraversesGenericTypesCorrectly() {
|
||||
assertThat(context.getPersistentPropertyPath("field.wrapped.field", Outer.class)).hasSize(3);
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright 2017 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.mapping.context
|
||||
|
||||
/**
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
data class SimpleDataClass(val firstname: String) {
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2017 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.mapping.context
|
||||
|
||||
/**
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
class TypeCreatingSyntheticClass {
|
||||
}
|
||||
|
||||
fun foobar(args: Array<String>) {
|
||||
}
|
||||
Reference in New Issue
Block a user