Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 1998, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
// Contributors:
// Oracle - initial API and implementation from Oracle TopLink
package org.eclipse.persistence.internal.indirection;
import org.eclipse.persistence.exceptions.DescriptorException;
import org.eclipse.persistence.exceptions.IntegrityChecker;
import org.eclipse.persistence.indirection.ValueHolderInterface;
import org.eclipse.persistence.internal.descriptors.DescriptorIterator;
import org.eclipse.persistence.internal.identitymaps.CacheKey;
import org.eclipse.persistence.internal.sessions.AbstractRecord;
import org.eclipse.persistence.internal.sessions.AbstractSession;
import org.eclipse.persistence.internal.sessions.MergeManager;
import org.eclipse.persistence.internal.sessions.UnitOfWorkImpl;
import org.eclipse.persistence.internal.sessions.remote.ObjectDescriptor;
import org.eclipse.persistence.internal.sessions.remote.RemoteValueHolder;
import org.eclipse.persistence.mappings.CollectionMapping;
import org.eclipse.persistence.mappings.DatabaseMapping;
import org.eclipse.persistence.mappings.ForeignReferenceMapping;
import org.eclipse.persistence.mappings.ObjectReferenceMapping;
import org.eclipse.persistence.mappings.foundation.AbstractTransformationMapping;
import org.eclipse.persistence.queries.ObjectLevelReadQuery;
import org.eclipse.persistence.queries.ReadObjectQuery;
import org.eclipse.persistence.queries.ReadQuery;
import org.eclipse.persistence.sessions.remote.DistributedSession;
import java.io.Serializable;
import java.util.Map;
/**
*
Purpose
:
*
* An IndirectionPolicy acts as a 'rules' holder that determines
* the behavior of a ForeignReferenceMapping (or TransformationMapping)
* with respect to indirection, or lack thereof.
*
*
Description
:
*
* IndirectionPolicy is an abstract class that defines the protocol to be implemented by
* subclasses so that the assorted DatabaseMappings can use an assortment of
* indirection policies:
*
no indirection policy (read everything from database)
*
*
* @see ForeignReferenceMapping
* @author Mike Norman
* @since TOPLink/Java 2.5
*/
public abstract class IndirectionPolicy implements Cloneable, Serializable {
protected DatabaseMapping mapping;
/**
* INTERNAL:
* Construct a new indirection policy.
*/
protected IndirectionPolicy() {
super();
}
/**
* INTERNAL:
* Return a backup clone of the attribute.
*/
public Object backupCloneAttribute(Object attributeValue, Object clone, Object backup, UnitOfWorkImpl unitOfWork) {
return this.mapping.buildBackupCloneForPartObject(attributeValue, clone, backup, unitOfWork);
}
/**
* INTERNAL
* Return true if the refresh should refresh on this mapping or not.
*/
protected ReadObjectQuery buildCascadeQuery(MergeManager mergeManager) {
ReadObjectQuery query = new ReadObjectQuery();
if (this.mapping.getReferenceDescriptor() != null) {
query.setReferenceClass(this.mapping.getReferenceDescriptor().getJavaClass());
}
if (mergeManager.shouldCascadeAllParts()) {
query.cascadeAllParts();
query.refreshIdentityMapResult();
}
if (mergeManager.shouldCascadePrivateParts() && getForeignReferenceMapping().isPrivateOwned()) {
query.cascadePrivateParts();
query.refreshIdentityMapResult();
}
return query;
}
/**
* INTERNAL: This method can be used when an Indirection Object is required
* to be built from a provided ValueHolderInterface object. This may be used
* for custom value holder types. Certain policies like the
* TransparentIndirectionPolicy may wrap the valueholder in another object.
*/
public abstract Object buildIndirectObject(ValueHolderInterface valueHolder);
/**
* INTERNAL:
* Clones itself.
*/
@Override
public Object clone() {
try {
return super.clone();
} catch (CloneNotSupportedException e) {
throw new InternalError();
}
}
/**
* INTERNAL:
* Return a clone of the attribute.
* @param buildDirectlyFromRow indicates that we are building the clone
* directly from a row as opposed to building the original from the
* row, putting it in the shared cache, and then cloning the original.
*/
public abstract Object cloneAttribute(Object attributeValue, Object original, CacheKey cacheKey, Object clone, Integer refreshCascade, AbstractSession cloningSession, boolean buildDirectlyFromRow);
/**
* INTERNAL:
* Return the primary key for the reference object (i.e. the object
* object referenced by domainObject and specified by mapping).
* This key will be used by a RemoteValueHolder.
*/
public Object extractPrimaryKeyForReferenceObject(Object referenceObject, AbstractSession session) {
return getOneToOneMapping().extractPrimaryKeysFromRealReferenceObject(referenceObject, session);
}
/**
* INTERNAL:
* Return the reference row for the reference object.
* This allows the new row to be built without instantiating
* the reference object.
* Return null if the object has already been instantiated.
*/
public abstract AbstractRecord extractReferenceRow(Object referenceObject);
/**
* INTERNAL:
* An object has been serialized from the server to the client.
* Replace the transient attributes of the remote value holders
* with client-side objects.
*/
public abstract void fixObjectReferences(Object object, Map