You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Discrepency between Neo4jTemplate saveAs and saveAllAs #2407
It appears that saveAllAs saves all properties regardless of whether those properties are in the projection passed as the Class<R> resultType parameter, while saveAs only saves the properties that are in the projection.
On the other hand, relationships seem to behave the same for both, if the relationship isn't included in the projection then it is not saved.
The expected behavior is that properties behave just like relationships for both saveAs and saveAllAs.
Hi @jposthauer What do you mean with by "only saves the properties that are in the projection." ? Non null values or actual present fields regardless of their value? I can't reproduce this in our test:
Below is the general setup we are trying to use. Once the last line is called it's still saving both first and last name instead of just the last name, while the relationship is not saved (expected).
@Node
public class Person {
@Property
private String firstName;
@Property
private String lastName;
@Relationship("HAS_CHILD")
private List<Person> children;
}
public interface PersonWithOnlyLastName {
String getLastName();
}
Person person = new Person("John","Doe")
Person child = new Person("Jane", "Doe"
person.children = listOf(child)
Neo4jTemplate.saveAllAs(listOf(person, child), PersonWithOnlyLastName.class)
Apologies, I fixed my example to use saveAllAs(). To clarify we don't get this issue on saveAs, only saveAllAs.
Also we see this issue even with entities that only have properties and no relationships.
Activity
jposthauer commentedon Oct 18, 2021
Spring Data Neo4j: 6.1.5
michael-simons commentedon Oct 19, 2021
Hi @jposthauer What do you mean with by "only saves the properties that are in the projection." ? Non null values or actual present fields regardless of their value? I can't reproduce this in our test:
spring-data-neo4j/src/test/java/org/springframework/data/neo4j/integration/imperative/Neo4jTemplateIT.java
Lines 551 to 577 in 09304bf
This saves only the last names (fields that are included in the projection)
jposthauer commentedon Oct 19, 2021
Below is the general setup we are trying to use. Once the last line is called it's still saving both first and last name instead of just the last name, while the relationship is not saved (expected).
michael-simons commentedon Oct 19, 2021
But you are using
saveAs, notsaveAllAsThere are tests for that exact scenario.
Note: The projection won't be applied to the relationship (the children won't be project…)
Can it be that your child elements have a back reference to the parent?
jposthauer commentedon Oct 19, 2021
Apologies, I fixed my example to use saveAllAs(). To clarify we don't get this issue on saveAs, only saveAllAs.
Also we see this issue even with entities that only have properties and no relationships.
GH-2407 - Add more tests.
michael-simons commentedon Oct 19, 2021
No worries, all good.
But sorry from my side, I need more input. I cannot reproduce it, see the added tests here: a7e7acf
jposthauer commentedon Oct 19, 2021
We will do more investigation on our end to see what's causing it with our setup.
jposthauer commentedon Oct 20, 2021
I was able to replicate the issue with a simple app: https://github.com/jposthauer/SimpleApp/blob/master/src/test/java/com/example/ApplicationTests.java
The first test passes but the second does not.
michael-simons commentedon Oct 21, 2021
Thank you, I can reproduce this now. Expect a fix soon.
GH-2407 - Apply property filter to binder function in case of single …
michael-simons commentedon Oct 21, 2021
Thanks again for reporting this @jposthauer and providing the reproducer, much appreciated and valuable.
spring-projectsGH-2407 - Apply property filter to binder function in …