@ Override public void delete ( Object entity , Object key ) { // All Modifying Neo4J operations must be executed within a transaction checkActiveTransaction ( ) ; GraphDatabaseService graphDb = getConnection ( ) ; // Find Node for this particular entity EntityMetadata m = KunderaMetadataManager . getEntityMetadata ( kunderaMetadata , entity . getClass ( ) ) ; Node node = mapper . searchNode ( key , m , graphDb , true ) ; if ( node != null ) { // Remove this particular node, if not already deleted in current // transaction if ( ! ( ( Neo4JTransaction ) resource ) . containsNodeId ( node . getId ( ) ) ) { node . delete ( ) ; // Manually remove node index if applicable indexer . deleteNodeIndex ( m , graphDb , node ) ; // Remove all relationship edges attached to this node // (otherwise an // exception is thrown) for ( Relationship relationship : node . getRelationships ( ) ) { relationship . delete ( ) ; // Manually remove relationship index if applicable indexer . deleteRelationshipIndex ( m , graphDb , relationship ) ; } ( ( Neo4JTransaction ) resource ) . addNodeId ( node . getId ( ) ) ; } } else { if ( log . isDebugEnabled ( ) ) log . debug ( "Entity to be deleted doesn't exist in graph. Doing nothing" ) ; } }
Deletes an entity from database .