diff --git a/pom.xml b/pom.xml index 9755be8f7..28121ce36 100644 --- a/pom.xml +++ b/pom.xml @@ -41,7 +41,7 @@ multi - 3.2.18 + 3.2.20 2.2.13.BUILD-SNAPSHOT diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/mapping/AnnotationScanningTests.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/mapping/AnnotationScanningTests.java index a05c6f69f..03efc8286 100644 --- a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/mapping/AnnotationScanningTests.java +++ b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/mapping/AnnotationScanningTests.java @@ -23,6 +23,7 @@ import org.neo4j.ogm.metadata.AnnotationsInfo; import org.neo4j.ogm.session.SessionFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; +import org.springframework.data.neo4j.mapping.gh1568.EntityWithSpringTransientProperties; import org.springframework.data.neo4j.test.Neo4jIntegrationTest; import org.springframework.test.context.junit4.SpringRunner; @@ -44,9 +45,21 @@ public class AnnotationScanningTests { .isEqualTo("foobar"); } + @Test // GH-1568 + public void shouldNotStoreOrTouchTransientProperties() { + + EntityWithSpringTransientProperties t = new EntityWithSpringTransientProperties("Hallo"); + t.setShouldNotBeThere("foobar"); + sessionFactory.openSession().save(t); + + t = sessionFactory.openSession().load(EntityWithSpringTransientProperties.class, t.getId()); + + assertThat(t.getShouldNotBeThere()).isNull(); + } + @Configuration @Neo4jIntegrationTest( - domainPackages = { "org.springframework.data.neo4j.mapping.datagraph1303" }, + domainPackages = { "org.springframework.data.neo4j.mapping.datagraph1303", "org.springframework.data.neo4j.mapping.gh1568" }, repositoryPackages = { "org.springframework.data.neo4j.mapping.datagraph1303" } ) static class Config { diff --git a/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/mapping/gh1568/EntityWithSpringTransientProperties.java b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/mapping/gh1568/EntityWithSpringTransientProperties.java new file mode 100644 index 000000000..e1b99e4df --- /dev/null +++ b/spring-data-neo4j/src/test/java/org/springframework/data/neo4j/mapping/gh1568/EntityWithSpringTransientProperties.java @@ -0,0 +1,56 @@ +/* + * Copyright 2011-2021 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.neo4j.mapping.gh1568; + +import org.neo4j.ogm.annotation.GeneratedValue; +import org.neo4j.ogm.annotation.Id; +import org.neo4j.ogm.annotation.NodeEntity; +import org.springframework.data.annotation.Transient; + +/** + * @author Michael J. Simons + * @soundtrack Evanescence - Fallen + */ +@NodeEntity +public class EntityWithSpringTransientProperties { + + @Id @GeneratedValue + private Long id; + + private String name; + + @Transient private String shouldNotBeThere; + + public EntityWithSpringTransientProperties(String name) { + this.name = name; + } + + public Long getId() { + return id; + } + + public String getName() { + return name; + } + + public String getShouldNotBeThere() { + return shouldNotBeThere; + } + + public void setShouldNotBeThere(String shouldNotBeThere) { + this.shouldNotBeThere = shouldNotBeThere; + } +}