Package org.eclipse.persistence.internal.identitymaps

Examples of org.eclipse.persistence.internal.identitymaps.CacheKey


        ClassDescriptor descriptor = getSession().getDescriptor(object);
        Vector key = descriptor.getObjectBuilder().extractPrimaryKeyFromObject(object, getSession());
        objectDescriptor.setKey(key);
        objectDescriptor.setWriteLockValue(getSession().getIdentityMapAccessorInstance().getWriteLockValue(key, object.getClass(), descriptor));
        objectDescriptor.setObject(object);
        CacheKey cacheKey = getSession().getIdentityMapAccessorInstance().getCacheKeyForObjectForLock(key, object.getClass(), descriptor);

        // Check for null because when there is NoIdentityMap, CacheKey will be null
        if (cacheKey != null) {
            objectDescriptor.setReadTime(cacheKey.getReadTime());
        }
        return objectDescriptor;
    }
View Full Code Here


        if (isXmlDescriptor() && ((XMLDescriptor)getDescriptor()).shouldPreserveDocument()) {
            Object pk = extractPrimaryKeyFromObject(object, session);
            if ((pk == null) || (pk instanceof CacheId) && (((CacheId)pk).getPrimaryKey().length == 0)) {
                pk = new CacheId(new Object[]{ new WeakObjectWrapper(object) });
            }
            CacheKey cacheKey = session.getIdentityMapAccessorInstance().getCacheKeyForObject(pk, getDescriptor().getJavaClass(), getDescriptor(), false);
            if ((cacheKey != null) && (cacheKey.getRecord() != null)) {
                XMLRecord nestedRecord = (XMLRecord)cacheKey.getRecord();
                nestedRecord.setMarshaller(parentRecord.getMarshaller());
                nestedRecord.setLeafElementType(parentRecord.getLeafElementType());
                parentRecord.setLeafElementType((XPathQName)null);
                return buildIntoNestedRow(nestedRecord, object, session);
            }
View Full Code Here

         Enumeration objects = map.keys();
         if (!objects.hasMoreElements()) {
             ((AbstractSession)session).log(SessionLog.INFO, SessionLog.SERVER, "jmx_mbean_runtime_services_identity_map_empty", className);
         }

         CacheKey cacheKey;
         while (objects.hasMoreElements()) {
             cacheKey = (CacheKey)objects.nextElement();
             ((AbstractSession)session).log(SessionLog.INFO, SessionLog.SERVER, "jmx_mbean_runtime_services_print_cache_key_value",
                     cacheKey.getKey().toString(), cacheKey.getObject().toString());
         }
     }
View Full Code Here

        if (row.isEmpty()) {
            return;
        }

        Object object = writeQuery.getObject();
        CacheKey cacheKey = null;
        ObjectChangeSet changeSet = writeQuery.getObjectChangeSet();
        if (changeSet != null){
            cacheKey = changeSet.getActiveCacheKey();
        }
View Full Code Here

     */
    protected CacheKey buildWrapperCacheKeyForAggregate(CacheKey owningCacheKey){
        if (isMapKeyMapping){
            return owningCacheKey;
        }
        CacheKey aggregateKey = null;
        if (owningCacheKey != null){
            Object object = owningCacheKey.getObject();
            if (owningCacheKey.getObject() != null){
                Object aggregate = getAttributeValueFromObject(object);
                aggregateKey = new CacheKey(null, aggregate, null);
                aggregateKey.setProtectedForeignKeys(owningCacheKey.getProtectedForeignKeys());
                aggregateKey.setRecord(owningCacheKey.getRecord());
                aggregateKey.setIsolated(owningCacheKey.isIsolated());
                aggregateKey.setReadTime(owningCacheKey.getReadTime());
            }
        }
        return aggregateKey;
    }
View Full Code Here

        Object pk = xmlDescriptor.getObjectBuilder().extractPrimaryKeyFromRow(row, session);
        if (xmlDescriptor.shouldPreserveDocument() || xmlDescriptor.getPrimaryKeyFieldNames().size() > 0) {
            if ((pk == null) || (((CacheId)pk).getPrimaryKey().length == 0)) {
                pk = new CacheId(new Object[]{ new WeakObjectWrapper(obj) });
            }
            CacheKey key = session.getIdentityMapAccessorInstance().acquireDeferredLock(pk, xmlDescriptor.getJavaClass(), xmlDescriptor);
            if ((xmlDescriptor).shouldPreserveDocument()) {
                key.setRecord(row);
            }
            key.setObject(obj);
            key.releaseDeferredLock();
        }
    }
View Full Code Here

        if(xmlDescriptor.shouldPreserveDocument()) {
            Object pk = xmlDescriptor.getObjectBuilder().extractPrimaryKeyFromObject(obj, session);
            if ((pk == null) || (pk instanceof CacheId) && (((CacheId)pk).getPrimaryKey().length == 0)) {
                pk = new CacheId(new Object[]{ new WeakObjectWrapper(obj) });
            }
            CacheKey cacheKey = session.getIdentityMapAccessorInstance().getCacheKeyForObject(pk, xmlDescriptor.getJavaClass(), xmlDescriptor,false);
            if(cacheKey != null && cacheKey.getRecord() != null) {
                return ((DOMRecord)cacheKey.getRecord()).getDOM();
            }
        }
        return null;
    }
View Full Code Here

        if (descriptor != null) {
            if (mergeManager.getSession().isUnitOfWork()) {
                // The unit of works will have a copy or a new instance must be made
                if (((UnitOfWorkImpl)mergeManager.getSession()).getLifecycle() == UnitOfWorkImpl.MergePending) {
                    // We are merging the unit of work into the original.
                    CacheKey cacheKey = getObjectFromSharedCacheForMerge(mergeManager, targetSession, getId(), descriptor);
                    if (cacheKey != null){
                        attributeValue = cacheKey.getObject();
                    }
                    if (attributeValue == null){
                        attributeValue = ((UnitOfWorkImpl)mergeManager.getSession()).getOriginalVersionOfObjectOrNull(getUnitOfWorkClone(), this, descriptor, targetSession);
                    }
                } else {
                    // We are merging something else within the unit of work.
                    // this is most likely because we are updating a backup clone and can retrieve
                    // the working clone as the result.
                    attributeValue = getUnitOfWorkClone();
                }
            } else {
                // It is not a unitOfWork so we must be merging into a distributed cache.
                CacheKey cacheKey = getObjectFromSharedCacheForMerge(mergeManager, targetSession, getId(), descriptor);
                this.activeCacheKey = cacheKey;
                if (cacheKey != null){
                    attributeValue = cacheKey.getObject();
                }
            }
       
            if ((attributeValue == null) && (shouldRead)) {
                // If the cache does not have a copy and I should read it from the database
View Full Code Here

    protected CacheKey getObjectFromSharedCacheForMerge(MergeManager mergeManager, AbstractSession session, Object primaryKey, ClassDescriptor descriptor){
        Object domainObject = null;
        if (primaryKey == null) {
            return null;
        }
        CacheKey cacheKey = session.getIdentityMapAccessorInstance().getCacheKeyForObject(primaryKey, descriptor.getJavaClass(), descriptor, true);
        if (cacheKey != null) {
            if (cacheKey.acquireReadLockNoWait()) {
                domainObject = cacheKey.getObject();
                cacheKey.releaseReadLock();
            } else {
                if (!mergeManager.isTransitionedToDeferredLocks()) {
                    session.getIdentityMapAccessorInstance().getWriteLockManager().transitionToDeferredLocks(mergeManager);
                }
                cacheKey.acquireDeferredLock();
                domainObject = cacheKey.getObject();
                if (domainObject == null) {
                    synchronized (cacheKey.getMutex()) {
                        if (cacheKey.isAcquired()) {
                            try {
                                cacheKey.getMutex().wait();
                            } catch (InterruptedException e) {
                                //ignore and return
                            }
                        }
                        domainObject = cacheKey.getObject();
                    }
                }
                cacheKey.releaseDeferredLock();
            }
        }
        return cacheKey;
    }
View Full Code Here

     * transitioned to deferred locks and a deferred lock will be used.
     */
    @Override
    protected CacheKey getCacheKeyFromTargetSessionForMerge(Object implementation, ObjectBuilder builder, ClassDescriptor descriptor, MergeManager mergeManager){
        Object primaryKey = builder.extractPrimaryKeyFromObject(implementation, this, true);
        CacheKey cacheKey = getIdentityMapAccessorInstance().getCacheKeyForObject(primaryKey, implementation.getClass(), descriptor, true);
        return cacheKey;
    }
View Full Code Here

TOP

Related Classes of org.eclipse.persistence.internal.identitymaps.CacheKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.