GH-1568 - Recognize org.springframework.data.annotation.Transient from Neo4j-OGM.

This is implemented with an update to Neo4j-OGM 3.2.20 and closes #1568.
This commit is contained in:
Michael Simons
2021-01-22 10:58:55 +01:00
parent 466e910b18
commit ae87b914d2
3 changed files with 71 additions and 2 deletions

View File

@@ -41,7 +41,7 @@
<project.type>multi</project.type>
<neo4j.ogm.version>3.2.18</neo4j.ogm.version>
<neo4j.ogm.version>3.2.20</neo4j.ogm.version>
<springdata.commons>2.2.13.BUILD-SNAPSHOT</springdata.commons>
</properties>

View File

@@ -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 {

View File

@@ -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;
}
}