@Override public void handleFlush(NodeStateContext nodeStateContext) { // Entity state to remain as Managed // Flush this node to database Client client = nodeStateContext.getClient(); client.persist((Node) nodeStateContext); // logNodeEvent("FLUSHED", this, nodeStateContext.getNodeId()); // Since node is flushed, mark it as NOT dirty nodeStateContext.setDirty(false); }
@Override public void handleRemove(NodeStateContext nodeStateContext) { // Managed ---> Removed moveNodeToNextState(nodeStateContext, new RemovedState()); // Mark entity for removal in persistence context nodeStateContext.setDirty(true); // Recurse remove operation for all related entities for whom // cascade=ALL or REMOVE // recursivelyPerformOperation(nodeStateContext, OPERATION.REMOVE); }
@Override public void handlePersist(NodeStateContext nodeStateContext) { // Transient ---> Managed moveNodeToNextState(nodeStateContext, new ManagedState()); // Mark this entity for saving in database nodeStateContext.setDirty(true); // Add this node into persistence cache nodeStateContext.getPersistenceCache().getMainCache().addNodeToCache((Node) nodeStateContext); // Recurse persist operation on all managed entities for whom // cascade=ALL or PERSIST // recursivelyPerformOperation(nodeStateContext, OPERATION.PERSIST); }
@Override public void handleFlush(NodeStateContext nodeStateContext) { // Entity state to remain as Removed // Flush this node to database Client client = nodeStateContext.getClient(); Node node = (Node) nodeStateContext; Object entityId = node.getEntityId(); client.remove(node.getData(), entityId); // Since node is flushed, mark it as NOT dirty nodeStateContext.setDirty(false); // Remove this node from Persistence Cache nodeStateContext.getPersistenceCache().getMainCache().removeNodeFromCache(node); }
nodeStateContext.setDirty(false);