Re: [Neo4j] delete a relationship

141 views
Skip to first unread message

Michael Hunger

unread,
Sep 1, 2012, 3:20:52 PM9/1/12
to ne...@googlegroups.com
You missed tx.success()

Sent from mobile device

Am 01.09.2012 um 17:42 schrieb darbon <samu...@msn.com>:

Hi, i'm new to neo4j and i have a problem. I need to delete all the relationships that i have inserted and i execute two times this function

public static void deleteRelationships(){
ArrayList<Node> listnodes =getNodes();
Transaction tx = graphDb.beginTx();
int cnt=0;
try
{
for (int i = 0; i < listnodes.size(); i++) {
Iterator<Relationship> iter = listnodes.get(i).getRelationships().iterator();
while(iter.hasNext())
{iter.next().delete();
cnt++;
}

}
}
catch (Exception e)
{
tx.failure();
e.printStackTrace();
}
finally
{
System.out.println("relationships deleted "+cnt);
tx.finish();
}
}

this function print 1600 two times. Anyone can help me? Thanks

--
 
 

darbon

unread,
Sep 1, 2012, 5:14:31 PM9/1/12
to ne...@googlegroups.com
mhhh...a day waste =) Thanks
Reply all
Reply to author
Forward
0 new messages