Skip to content

Commit 0aa1504

Browse files
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.
1 parent ce08b44 commit 0aa1504

File tree

3 files changed

+71
-2
lines changed

3 files changed

+71
-2
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
<project.type>multi</project.type>
4343

44-
<neo4j.ogm.version>3.2.18</neo4j.ogm.version>
44+
<neo4j.ogm.version>3.2.20</neo4j.ogm.version>
4545
<springdata.commons>2.3.7.BUILD-SNAPSHOT</springdata.commons>
4646
</properties>
4747

spring-data-neo4j/src/test/java/org/springframework/data/neo4j/mapping/AnnotationScanningTests.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.neo4j.ogm.session.SessionFactory;
2424
import org.springframework.beans.factory.annotation.Autowired;
2525
import org.springframework.context.annotation.Configuration;
26+
import org.springframework.data.neo4j.mapping.gh1568.EntityWithSpringTransientProperties;
2627
import org.springframework.data.neo4j.test.Neo4jIntegrationTest;
2728
import org.springframework.test.context.junit4.SpringRunner;
2829

@@ -44,9 +45,21 @@ public void shouldBeAbleToWorkWithAnnotatedAnnotations() {
4445
.isEqualTo("foobar");
4546
}
4647

48+
@Test // GH-1568
49+
public void shouldNotStoreOrTouchTransientProperties() {
50+
51+
EntityWithSpringTransientProperties t = new EntityWithSpringTransientProperties("Hallo");
52+
t.setShouldNotBeThere("foobar");
53+
sessionFactory.openSession().save(t);
54+
55+
t = sessionFactory.openSession().load(EntityWithSpringTransientProperties.class, t.getId());
56+
57+
assertThat(t.getShouldNotBeThere()).isNull();
58+
}
59+
4760
@Configuration
4861
@Neo4jIntegrationTest(
49-
domainPackages = { "org.springframework.data.neo4j.mapping.datagraph1303" },
62+
domainPackages = { "org.springframework.data.neo4j.mapping.datagraph1303", "org.springframework.data.neo4j.mapping.gh1568" },
5063
repositoryPackages = { "org.springframework.data.neo4j.mapping.datagraph1303" }
5164
)
5265
static class Config {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright 2011-2021 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.data.neo4j.mapping.gh1568;
17+
18+
import org.neo4j.ogm.annotation.GeneratedValue;
19+
import org.neo4j.ogm.annotation.Id;
20+
import org.neo4j.ogm.annotation.NodeEntity;
21+
import org.springframework.data.annotation.Transient;
22+
23+
/**
24+
* @author Michael J. Simons
25+
* @soundtrack Evanescence - Fallen
26+
*/
27+
@NodeEntity
28+
public class EntityWithSpringTransientProperties {
29+
30+
@Id @GeneratedValue
31+
private Long id;
32+
33+
private String name;
34+
35+
@Transient private String shouldNotBeThere;
36+
37+
public EntityWithSpringTransientProperties(String name) {
38+
this.name = name;
39+
}
40+
41+
public Long getId() {
42+
return id;
43+
}
44+
45+
public String getName() {
46+
return name;
47+
}
48+
49+
public String getShouldNotBeThere() {
50+
return shouldNotBeThere;
51+
}
52+
53+
public void setShouldNotBeThere(String shouldNotBeThere) {
54+
this.shouldNotBeThere = shouldNotBeThere;
55+
}
56+
}

0 commit comments

Comments
 (0)