-
Notifications
You must be signed in to change notification settings - Fork 617
SDN6.3.0 Used Unwind & Merge when the parameter is not empty but run failed #2579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@michael-simons I'm very happy to see the issues #2576, and then I try to modify my code :
Now,It works very well,thank you! |
Hi @walkonbench now you beat me to it in a response. Here's another solution I wrote up for a test case: public interface TableRepository extends Neo4jRepository<TableNode, Long> {
@Query(value =
"UNWIND :#{#froms} AS col " +
"WITH col.__properties__ AS col, :#{#to}.__properties__ AS to " +
"MERGE (c:Column { sourceName : col.sourceName, " +
"schemaName : col.schemaName, " +
"tableName : col.tableName, " +
"name : col.name }) " +
"MERGE (t:Table {sourceName : to.sourceName, " +
"schemaName : to.schemaName, " +
"name : to.name }) " +
"MERGE (c) -[r:BELONG]-> (t) ")
void mergeTableAndColumnRelations(@Param("froms") List<ColumnNode> froms, @Param("to") TableNode to);
} Let's dig to it, what are we seeing? We tried to design a map-based generic model to pass the value of objects towards Cypher. In the modified query I do unwrap the properties once and use Personally, I would prefer my solution as it keeps the domain model intact and does not convert things to a map. |
@michael-simons Thank you very much. When I first saw this method to complete this thing, it was undoubtedly a better solution. I like it very much. Thank you again, ha ha |
Hi, @michael-simons I'm considering switching to this way of bulk inserting and it would be interesting to know its performance compared to a repository.save() inside a loop. Thanks |
Hi,I just started to contact neo4j with springboot and import
spring-boot-starter-data-neo4j:2.7.2
But I don't think I'm going well and got an error :
org.neo4j.driver.exceptions.ClientException: Cannot merge the following node because of null property value for 'name': (:Column {name: null})
I know Merge cant't work with null properties,This should not be the problem
Okay now, I have a column node:
and a table node:
with TableAndColumnRelation:
Then, I want to establish a relationship between multiple column nodes and a table node with the statement:
Here are the attributes of 'froms' and 'to':
We can see the attributes of 'froms' not null and it can inject to
:#{#froms}
, the properties of variablecol
is{name: "h", sourceName: "B", schemaName: "B", tableName: "B"}
, but Merge run failed it seems thatcol.name
is null:org.neo4j.driver.exceptions.ClientException: Cannot merge the following node because of null property value for 'name': (:Column {name: null})
However, it works well when I do not use unwind and use a field to associate with a table like this :
This is the log stack I printed out
Looking forward to receiving your reply!
The text was updated successfully, but these errors were encountered: