title: Neo4j: Get the value for a deleted property
body: <p>I am using transaction event handlers to do security checking on deleted nodes, to make sure whether a current user is allowed to do this. </p>
  
  <p>To make sure I have the right node to check I first have to find out whether it has a certain property and then check the value of another property, so ideally the code should be something like this:</p>
  
  <pre><code>        graphDatabaseService.registerTransactionEventHandler(new TransactionEventHandler.Adapter&lt;Object&gt;() {
          @Override
          public Object beforeCommit(TransactionData data) throws Exception {
              for (Node node : data.deletedNodes()) {
                  if (node.hasProperty("checkProperty")){
                      if (node.hasProperty("propertyToCheck")){
                          String value = (String) node.getProperty("propertyToCheck");
                          ... do checking on value
                      }
                  }
              }
              return null;
          }
  </code></pre>
  
  <p>But this fails with exception</p>
  
  <pre><code>Caused by: java.lang.IllegalStateException: Node[11] has been deleted in this tx
  at org.neo4j.kernel.impl.core.WritableTransactionState$CowEntityElement.assertNotDeleted(WritableTransactionState.java:141)
  at org.neo4j.kernel.impl.core.WritableTransactionState$CowEntityElement.getPropertyAddMap(WritableTransactionState.java:129)
  at org.neo4j.kernel.impl.core.WritableTransactionState$CowNodeElement.getPropertyAddMap(WritableTransactionState.java:155)
  at org.neo4j.kernel.impl.core.WritableTransactionState.getCowPropertyAddMap(WritableTransactionState.java:529)
  at org.neo4j.kernel.impl.core.Primitive.hasProperty(Primitive.java:306)
  at org.neo4j.kernel.impl.core.NodeImpl.hasProperty(NodeImpl.java:53)
  at org.neo4j.kernel.impl.core.NodeProxy.hasProperty(NodeProxy.java:160)
  </code></pre>
  
  <p>The only workaround I found is this:</p>
  
  <pre><code>            for (Node node : data.deletedNodes()) {
                  boolean check = false;
                  String valueToCheck = null;
                  for (PropertyEntry prop : data.removedNodeProperties()) {
                      if (node.equals(prop.entity())) {
                          if (prop.key().equals("checkProperty")) {
                              check = true;
                          }
                          if (prop.key().equals("propertyToCheck")) {
                              valueToCheck = (String) prop.previouslyCommitedValue();
                          }
                      }
                  }
                  if (check){
                      ... do checking on value
                  }
  
              }
  </code></pre>
  
  <p>But this goes through ALL deleted properties, so this is obviously not a nice solution. </p>
  
  <p>So my question is: is there a better way to do this?</p>
  
  <p>Using neo4j 1.9.3</p>