Is it possible to determine if a Node
is in a transaction? It is possible to get a GraphDatabaseService
by the method Node.getGraphDatabase
.
I would like to do something like this:
public class Neo4JHelper {
public void setProperty(Node node, String key, Object value) {
if(isInTransaction(node) {
node.setProperty(key, value);
} else {
throw new MyOwnException("You are trying to set a node outside a transaction... you suck");
}
}
private boolean isInTransaction(Node node) {
//Something
}
}
The reason I want to do this is because I would like to give my users a custom error when trying to use my class Neo4JHelper
outside a transaction.
Another solution would be if it is possible to somehow tell the compiler that you need a transaction to use the method/class and otherwise give a compile error.