cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

@Properties how do I delete an item from a node

I have this map setup:
@Properties
private Map<String, String> alternateIds = new HashMap<>();

I want to be able to remove items and I thought I would be able to just do something simple like this:
public void setAlternateIds(Map<String, String> alternateIds) {
this.alternateIds = alternateIds;
}

But when I do that and my map on the actual node has more items in it. They stay on the node and are never wiped out. Any ideas on how I can delete an item from this?

10 REPLIES 10

I have also tried specifically removing all items from the map on my Entity and then saving. Still seems as those any item in the map stays in the graph

I can indeed do something like this in cypher tho

match (n) where n._id ="17fa667f-d004-4a52-8715-6ab2e779d5e9" remove n.alternateIds.ECRM_ID remove n.alternateIds.GLOBAL remove n.alternateIds.SOURCE_ID remove n.alternateIds.CLASSIC_NODE_ID return n

and remove each item manually

Hi,
I'm sad to say that this is probably a bug. I can reproduce the behavior with our issue template.

@gerrit.meier Please let us know what you think. If you agree that the properties should be deleted, I'll create a bug.

Yes I have seen this behaviour before and I am 99% sure that this is a bug.

Related StackOverflow question: https://stackoverflow.com/questions/51374111/how-to-remove-the-properties-of-map-in-neo4j/51391308

Will be fixed in 3.2 and probably in 3.1.6 as well.

Still not working using spring-data-neo4j-2.2.7.RELEASE with neo4j-ogm-core-3.2.x as transitive dependency. Method I am using is repository.save()

Edit: version I am talking about is org.springframework.boot:spring-boot-starter-data-neo4j:2.2.7.RELEASE

As Michael already asked for here: @Properties in a Map attribute of a @NodeEntity cannot be deleted. · Issue #518 · neo4j/neo4j-ogm · ...
A reproducer would be helpful for us. (And please no cross-posting)
Did you mean Spring Data Neo4j 5.2.7? Because 2.2.7 does not really make a lot of sense.

Correct @gerrit.meier, Spring Data Neo4j 5.2.7 is the version. And unfortunately I don't have handy reproducible version. Just wanted to know if that is something you tested - that is, without using Session object, thanks.

Problem was on our side. We were using session.clear() in between operations. There is nothing to be concerned of @gerrit.meier and @michael.simons.

Sorry for cross-posting and thanks.

Thanks for your feedback, @lorenzo.valente.91 much appreciated.

Yes indeed, session.clear() is indeed dangerous in that regard: It demarks the transaction boundary and I agree, it's to easy to nuke it away.

Glad you figured it out.