/** * Rollback. * * @param delegator * the delegator */ public void commit() { onCommit(eventLogQueue.getInsertEvents()); onCommit(eventLogQueue.getUpdateEvents()); onCommit(eventLogQueue.getDeleteEvents()); }
/** * Map containing data required for inserting records for each join table. * Key -> Name of Join Table Value -> records to be persisted in the join * table */ // private Map<String, JoinTableData> joinTableDataMap; public PersistenceCache() { initialize(null,this); }
/** * Check if the instance is a managed entity instance belonging to the * current persistence context. */ boolean contains(Object entity) { Node node = getPersistenceCache().getMainCache().getNodeFromCache(entity, getMetadata(entity.getClass()), this); return node != null && node.isInState(ManagedState.class); }
/** * Rollback. * * @param delegator * the delegator */ public void rollback(PersistenceDelegator delegator) { if (eventLogQueue != null) { onRollBack(delegator, eventLogQueue.getInsertEvents()); onRollBack(delegator, eventLogQueue.getUpdateEvents()); onRollBack(delegator, eventLogQueue.getDeleteEvents()); rollbackJoinTableData(delegator); } }
public void markAllNodesNotTraversed() { for (Node node : persistenceCache.getMainCache().getAllNodes()) { node.setTraversed(false); } /* for (Node node : persistenceCache.getEmbeddedCache().getAllNodes()) { node.setTraversed(false); } for (Node node : persistenceCache.getElementCollectionCache().getAllNodes()) { node.setTraversed(false); } for (Node node : persistenceCache.getTransactionalCache().getAllNodes()) { node.setTraversed(false); }*/ }
void rollback() { flushManager.rollback(this); flushManager.clearFlushStack(); getPersistenceCache().clean(); isTransactionInProgress = false; }
@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); }
void commit() { enableFlush = true; execute(); flushManager.commit(); flushManager.clearFlushStack(); isTransactionInProgress = false; enableFlush = false; }
void clear() { // Move all nodes tied to this EM into detached state flushManager.clearFlushStack(); getPersistenceCache().clean(); onClearProxy(); }
/** * @throws java.lang.Exception */ @Before public void setUp() throws Exception { PersistenceCache pc = new PersistenceCache(); pcm = new PersistenceCacheManager(pc); }
/** * @throws java.lang.Exception */ @Before public void setUp() throws Exception { flushManager = new FlushManager(); fs = flushManager.getFlushStack(); }
private void cleanIndividualCache(CacheBase cache) { for (Node node : cache.getAllNodes()) { node.clear(); } }
/** * @throws java.lang.Exception */ @Before public void setUp() throws Exception { pc = new PersistenceCache(); }
private void initialize(com.impetus.kundera.cache.Cache l2Cache, PersistenceCache pc) { mainCache = new MainCache(l2Cache,this); // embeddedCache = new EmbeddedCache(l2Cache); // elementCollectionCache = new ElementCollectionCache(l2Cache); // transactionalCache = new TransactionalCache(l2Cache); // flushStack = new FlushStack(); // joinTableDataMap = new HashMap<String, JoinTableData>(); // // flushManager = new FlushManager(); }
public void clearPersistenceCache() { persistenceCache.clean(); } // cleanIndividualCache(pc.getMainCache()); // cleanIndividualCache(pc.getEmbeddedCache());
public Node getNodeFromCache(String nodeId, PersistenceDelegator pd) { Node node = nodeMappings.get(nodeId); // if not present in first level cache, check from second level cache. return node != null ? node : lookupL2Cache(nodeId, pd); }
/** * Remove the given entity from the persistence context, causing a managed * entity to become detached. */ public void detach(Object entity) { Node node = getPersistenceCache().getMainCache().getNodeFromCache(entity, getMetadata(entity.getClass()), this); if (node != null) { node.detach(); } }
/** * On explicit call from em.flush(). */ void doFlush() { enableFlush = true; flush(); execute(); enableFlush = false; flushManager.commit(); flushManager.clearFlushStack(); }
public PersistenceCache(com.impetus.kundera.cache.Cache l2Cache) { initialize(l2Cache,this); }