Akhil, as Michael mentioned, if you take both directions of relationships, you are within the TX trying to remove the relationship from both ends, thus ending up with that error.
Cheers, /peter neubauer GTalk: neubauer.peter Skype peter.neubauer Phone +46 704 106975 LinkedIn http://www.linkedin.com/in/neubauer Twitter http://twitter.com/peterneubauer http://www.neo4j.org - Your high performance graph database. http://startupbootcamp.org/ - Öresund - Innovation happens HERE. http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party. On Sat, Apr 16, 2011 at 11:40 AM, Akhil <azk...@cse.psu.edu> wrote: > Ok, This is what i did, > i changed the line in the code to now look like this : by adding > "Direction.INCOMING" in the parameter and the error went away, > Iterable<Relationship> rel = node.getRelationships(Direction.INCOMING); > > I am curious on why this would have fixed this !! > And why > getRelationships() > OR getRelationships(Direction.BOTH) > AND getRelationships(Direction.OUTCOMING) would give errors. > > Akhillius > > On 4/16/2011 5:27 AM, Akhil wrote: >> I loaded close to 10k and 41k relationships nodes in the database and >> i then tried to delete all of the nodes and relationships. This is the >> following code below. >> >> public static void main(String[] args) { >> >> graphDb = new EmbeddedGraphDatabase(DB_PATH); >> nodeIndex = graphDb.index().forNodes(INDEX_NAME); >> GraphDbMethods.registerShutdownHook(graphDb); >> Transaction tx = graphDb.beginTx(); >> Iterable<Node> allNodes = graphDb.getAllNodes(); >> for (Node node : allNodes) { >> if (node.getId() != 0) { >> if (node.getId() != 0) { >> Iterable<Relationship> rel = node.getRelationships(); >> for (Relationship relationship : rel) { >> relationship.delete(); // error occurs here >> } >> node.delete(); >> } >> nodeIndex.remove(node); >> } >> } >> >> tx.success(); >> tx.finish(); >> System.out.println("Shutting down database ..."); >> graphDb.shutdown(); >> } >> >> >> I get the " illegalStateException:Relationship[3130] has been deleted >> in this tx" error and this transaction rolls back. >> >> Plz help >> >> Akhillius >> > > _______________________________________________ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > _______________________________________________ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user