Hi Stefan, I do not get any error, but the labels (with their nodes) are still there.
Alireza On Monday, September 8, 2014 11:32:30 AM UTC+2, Stefan Armbruster wrote: > > Your snippet looks good. What error do you get? Or how do you observe the > misbehaviour? > > > > 2014-09-08 10:49 GMT+02:00 Alireza Rezaei Mahdiraji <alire...@gmail.com > <javascript:>>: > >> >> Hi Michael, >> >> Any opinion why the code does not work? >> >> Thanks, >> Alireza >> >> On Saturday, August 30, 2014 1:27:00 AM UTC+2, Michael Hunger wrote: >>> >>> If you didn't miss tx.success() and used the same try-with-resource >>> pattern as Stefan it must work. >>> >>> Except if you're swallowing an exception. >>> >>> Michael >>> >>> Am 30.08.2014 um 01:16 schrieb Alireza Rezaei Mahdiraji < >>> alire...@gmail.com>: >>> >>> Hi Michael, >>> >>> Yeah I printed the nodes' info before deleting and it shows them. I have >>> not >>> print the relationships though, I think nodes would be enough, right? >>> >>> Thanks, >>> Alireza >>> >>> On Saturday, August 30, 2014 12:25:20 AM UTC+2, Michael Hunger wrote: >>>> >>>> Can you print out the node-ids and rel-ids that it iterates over? >>>> >>>> Did you use the correct label name >>>> >>>> Michael >>>> >>>> Am 30.08.2014 um 00:22 schrieb Alireza Rezaei Mahdiraji <alire...@ >>>> gmail.com>: >>>> >>>> >>>> Hi Stefan, >>>> >>>> I tied the Java code, it seems running but the nodes and relationships >>>> are not getting deleted. >>>> Also, there is no error. Any idea? >>>> >>>> Thanks, >>>> Alireza >>>> >>>> On Friday, August 29, 2014 4:59:32 PM UTC+2, Stefan Armbruster wrote: >>>>> >>>>> Since you can run cypher from java the following would be a valid (but >>>>> >>>>> probably not expected) answer: >>>>> new ExecutionEngine(graphDb).execute("match (n:MyLabel) optional >>>>> match(n)-[r]-() delete r,n"); >>>>> >>>>> In pure Java: >>>>> >>>>> try (Transaction tx=graphDb.beginTx()) { >>>>> for (Node n: >>>>> GlobalGraphOperations.at <http://globalgraphoperations.at/>( >>>>> graphDb).getAllNodesWithLabel(DynamicLabel.label("MyLabel"))) >>>>> { >>>>> for (Relationship r: n.getRelationships()) { >>>>> r.delete(); >>>>> } >>>>> n.delete(); >>>>> } >>>>> >>>>> tx.success(); >>>>> } >>>>> >>>>> NB: didn't test code above it's more a dump from /dev/brain ;-) >>>>> >>>>> /Stefan >>>>> >>>>> >>>>> 2014-08-29 12:35 GMT+02:00 Alireza Rezaei Mahdiraji < >>>>> alire...@gmail.com>: >>>>> > >>>>> > Hi All, >>>>> > >>>>> > How can I remove all nodes (and their relationships) with a given >>>>> label >>>>> > using Java? >>>>> > >>>>> > Thanks, >>>>> > Alireza >>>>> > >>>>> > -- >>>>> > You received this message because you are subscribed to the Google >>>>> Groups >>>>> > "Neo4j" group. >>>>> > To unsubscribe from this group and stop receiving emails from it, >>>>> send an >>>>> > email to neo4j+un...@googlegroups.com. >>>>> > For more options, visit https://groups.google.com/d/optout. >>>>> >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Neo4j" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to neo4j+un...@googlegroups.com. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>>> >>>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Neo4j" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to neo4j+un...@googlegroups.com. >>> For more options, visit https://groups.google.com/d/optout. >>> >>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "Neo4j" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to neo4j+un...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "Neo4j" group. To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.