Compare commits
6 Commits
issue/arch
...
issue/DATA
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ecb35886f9 | ||
|
|
2bca4c9a33 | ||
|
|
19d74427f1 | ||
|
|
4fb6a844dd | ||
|
|
51a35273d3 | ||
|
|
203d2d0187 |
4
pom.xml
4
pom.xml
@@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||
<version>3.3.0-SNAPSHOT</version>
|
||||
<version>3.3.0.DATAMONGO-2250-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Spring Data MongoDB</name>
|
||||
@@ -26,7 +26,7 @@
|
||||
<properties>
|
||||
<project.type>multi</project.type>
|
||||
<dist.id>spring-data-mongodb</dist.id>
|
||||
<springdata.commons>2.6.0-SNAPSHOT</springdata.commons>
|
||||
<springdata.commons>2.6.0.DATACMNS-1509-SNAPSHOT</springdata.commons>
|
||||
<mongo>4.2.3</mongo>
|
||||
<mongo.reactivestreams>${mongo}</mongo.reactivestreams>
|
||||
<jmh.version>1.19</jmh.version>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||
<version>3.3.0-SNAPSHOT</version>
|
||||
<version>3.3.0.DATAMONGO-2250-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||
<version>3.3.0-SNAPSHOT</version>
|
||||
<version>3.3.0.DATAMONGO-2250-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||
<version>3.3.0-SNAPSHOT</version>
|
||||
<version>3.3.0.DATAMONGO-2250-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -353,7 +353,7 @@ public class BasicMongoPersistentEntity<T> extends BasicPersistentEntity<T, Mong
|
||||
|
||||
if (existingProperty != null) {
|
||||
throw new MappingException(
|
||||
String.format(AMBIGUOUS_FIELD_MAPPING, property.toString(), existingProperty.toString(), fieldName));
|
||||
String.format(AMBIGUOUS_FIELD_MAPPING, property, existingProperty, fieldName));
|
||||
}
|
||||
|
||||
properties.put(fieldName, property);
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2019 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
|
||||
*
|
||||
* https://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.mongodb.core
|
||||
|
||||
import com.mongodb.client.MongoClients
|
||||
import org.junit.Test
|
||||
import org.springframework.data.mongodb.core.mapping.Field
|
||||
import org.springframework.data.mongodb.repository.MongoRepository
|
||||
import org.springframework.data.mongodb.repository.support.MongoRepositoryFactory
|
||||
import org.springframework.data.mongodb.test.util.Assertions.assertThat
|
||||
|
||||
open class SuperType(open var field: Int)
|
||||
|
||||
class SubType(val id: String, @Field("foo") override var field: Int = 1) :
|
||||
SuperType(field) {
|
||||
|
||||
fun setFields(v: Int) {
|
||||
field = v
|
||||
super.field = v
|
||||
}
|
||||
}
|
||||
|
||||
interface MyRepository : MongoRepository<SubType, String>
|
||||
|
||||
class `KotlinOverridePropertyTests` {
|
||||
|
||||
val template = MongoTemplate(MongoClients.create(), "kotlin-tests")
|
||||
|
||||
@Test // DATAMONGO-2250
|
||||
fun `Ambiguous field mapping for override val field`() {
|
||||
|
||||
val repository =
|
||||
MongoRepositoryFactory(template).getRepository(MyRepository::class.java)
|
||||
|
||||
var subType = SubType("id-1")
|
||||
subType.setFields(3)
|
||||
|
||||
repository.save(subType)
|
||||
|
||||
assertThat(repository.findById(subType.id).get().field).isEqualTo(subType.field)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user