Package org.eclipse.persistence.sessions
Class CopyGroup
- java.lang.Object
-
- org.eclipse.persistence.core.queries.CoreAttributeGroup<org.eclipse.persistence.internal.queries.AttributeItem,ClassDescriptor>
-
- org.eclipse.persistence.queries.AttributeGroup
-
- org.eclipse.persistence.sessions.CopyGroup
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
- Direct Known Subclasses:
ObjectCopyingPolicy
public class CopyGroup extends AttributeGroup
Purpose: Define how an object is to be copied.Description: This is for usage with the object copying feature, not the unit of work. This is useful for copying an entire object graph as part of the host application's logic.
Responsibilities:
- Indicate through CASCADE levels the depth relationships will copied.
- Indicate if PK attributes should be copied with existing value or should be reset.
- Copies only the attributes found in the group.
-
-
Field Summary
Fields Modifier and Type Field Description static intCASCADE_ALL_PARTSDepth level indicating that all relationships with mappings should be used when building the copied object graphstatic intCASCADE_PRIVATE_PARTSDepth level indicating that only relationships with mapping indicated privately- owned should be copiedstatic intCASCADE_TREEDepth level indicating that only the attributes found in the attribute group should be copiedprotected java.util.Mapcopiesprotected intdepthPolicy depth that determines how the copy will cascade to the object's related partsstatic intNO_CASCADEDepth level indicating that NO relationships should be included in the copy.protected org.eclipse.persistence.internal.sessions.AbstractSessionsessionprotected booleanshouldResetPrimaryKeyprotected booleanshouldResetVersion-
Fields inherited from class org.eclipse.persistence.core.queries.CoreAttributeGroup
allsubclasses, isValidated, items, name, subClasses, superClassGroup, type, typeName
-
-
Constructor Summary
Constructors Constructor Description CopyGroup()PUBLIC: By default only copy the attributes found in the attribute group and don't null primary keys.CopyGroup(java.lang.String name)PUBLIC: By default only copy the attributes found in the attribute group and don't null primary keys.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAttribute(java.lang.String attributeNameOrPath, CoreAttributeGroup group)Add a basic attribute or nested attribute with each String representing an attribute on the path to what needs to be included in the AttributeGroup.voidaddAttribute(java.lang.String attributeNameOrPath, CopyGroup group)voidcascadeAllParts()PUBLIC: Set if the copy should cascade all relationships when copying the object(s).voidcascadePrivateParts()PUBLIC: Set if the copy should cascade only those relationships that are configured as privately-owned.voidcascadeTree()PUBLIC: Set if the copy should cascade only those attributes that are found in the group.CopyGroupclone()voiddontCascade()PUBLIC: Set if the copy should not cascade relationships when copying the object(s)java.util.MapgetCopies()INTERNAL: Get the session.intgetDepth()INTERNAL: Return the cascade depth.CopyGroupgetGroup(java.lang.String attributeNameOrPath)Returns CopyGroup corresponding to the passed (possibly nested) attribute.org.eclipse.persistence.internal.sessions.AbstractSessiongetSession()INTERNAL: Return the session.booleanisCopyGroup()INTERNAL: This method is used internally when converting to a copy group.protected CopyGroupnewGroup(java.lang.String name, CoreAttributeGroup parent)Subclass may create different types.voidsetCopies(java.util.Map newCopies)INTERNAL: Set the copies.voidsetDepth(int newDepth)INTERNAL: Set the cascade depth.voidsetSession(org.eclipse.persistence.internal.sessions.AbstractSession newSession)INTERNAL: Set the session.voidsetShouldResetPrimaryKey(boolean newShouldResetPrimaryKey)PUBLIC: Set if the primary key should be reset to null.voidsetShouldResetVersion(boolean newShouldResetVersion)PUBLIC: Set if the version should be reset to null.booleanshouldCascade()PUBLIC: Return true if has been configured to CASCADE_ALL_PARTS or CASCADE_PRIVATE_PARTS.booleanshouldCascadeAllParts()PUBLIC: Return true if should CASCADE_ALL_PARTSbooleanshouldCascadePrivateParts()PUBLIC: Return true if should CASCADE_PRIVATE_PARTSbooleanshouldCascadeTree()PUBLIC: Return true if should CASCADE_TREEbooleanshouldResetPrimaryKey()PUBLIC: Return if the primary key should be reset to null.booleanshouldResetVersion()PUBLIC: Return if the version should be reset to null.protected java.lang.StringtoStringAdditionalInfo()INTERNAL:-
Methods inherited from class org.eclipse.persistence.queries.AttributeGroup
addAttribute, findGroup, getItem, isConcurrent, isLoadGroup, isSupersetOf, newItem, newItem, toCopyGroup, toCopyGroup, toFetchGroup, toFetchGroup, toLoadGroup, toLoadGroup
-
Methods inherited from class org.eclipse.persistence.core.queries.CoreAttributeGroup
addAttribute, addAttribute, addAttributeKey, addAttributes, clone, containsAttribute, containsAttributeInternal, convert, convertClassNamesToClasses, equals, getAllItems, getAttributeNames, getItem, getItems, getName, getSubClassGroups, getType, getTypeName, hashCode, hasInheritance, hasItems, insertSubClass, isFetchGroup, isSupersetOf, isValidated, removeAttribute, setAllSubclasses, setAttributeNames, setName, toString, toStringItems, toStringPath
-
-
-
-
Field Detail
-
shouldResetPrimaryKey
protected boolean shouldResetPrimaryKey
-
shouldResetVersion
protected boolean shouldResetVersion
-
session
protected transient org.eclipse.persistence.internal.sessions.AbstractSession session
-
copies
protected java.util.Map copies
-
depth
protected int depth
Policy depth that determines how the copy will cascade to the object's related parts
-
NO_CASCADE
public static final int NO_CASCADE
Depth level indicating that NO relationships should be included in the copy. Relationships that are not copied will include the default value of the object's instantiation policy- See Also:
- Constant Field Values
-
CASCADE_PRIVATE_PARTS
public static final int CASCADE_PRIVATE_PARTS
Depth level indicating that only relationships with mapping indicated privately- owned should be copied- See Also:
- Constant Field Values
-
CASCADE_ALL_PARTS
public static final int CASCADE_ALL_PARTS
Depth level indicating that all relationships with mappings should be used when building the copied object graph- See Also:
- Constant Field Values
-
CASCADE_TREE
public static final int CASCADE_TREE
Depth level indicating that only the attributes found in the attribute group should be copied- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CopyGroup
public CopyGroup()
PUBLIC: By default only copy the attributes found in the attribute group and don't null primary keys.
-
CopyGroup
public CopyGroup(java.lang.String name)
PUBLIC: By default only copy the attributes found in the attribute group and don't null primary keys.
-
-
Method Detail
-
cascadeAllParts
public void cascadeAllParts()
PUBLIC: Set if the copy should cascade all relationships when copying the object(s).
-
cascadePrivateParts
public void cascadePrivateParts()
PUBLIC: Set if the copy should cascade only those relationships that are configured as privately-owned.
-
cascadeTree
public void cascadeTree()
PUBLIC: Set if the copy should cascade only those attributes that are found in the group.
-
dontCascade
public void dontCascade()
PUBLIC: Set if the copy should not cascade relationships when copying the object(s)
-
getCopies
public java.util.Map getCopies()
INTERNAL: Get the session.
-
getDepth
public int getDepth()
INTERNAL: Return the cascade depth.
-
getSession
public org.eclipse.persistence.internal.sessions.AbstractSession getSession()
INTERNAL: Return the session.
-
setCopies
public void setCopies(java.util.Map newCopies)
INTERNAL: Set the copies.
-
setDepth
public void setDepth(int newDepth)
INTERNAL: Set the cascade depth.
-
setSession
public void setSession(org.eclipse.persistence.internal.sessions.AbstractSession newSession)
INTERNAL: Set the session.
-
setShouldResetPrimaryKey
public void setShouldResetPrimaryKey(boolean newShouldResetPrimaryKey)
PUBLIC: Set if the primary key should be reset to null.
-
setShouldResetVersion
public void setShouldResetVersion(boolean newShouldResetVersion)
PUBLIC: Set if the version should be reset to null.
-
shouldCascade
public boolean shouldCascade()
PUBLIC: Return true if has been configured to CASCADE_ALL_PARTS or CASCADE_PRIVATE_PARTS.
-
shouldCascadeAllParts
public boolean shouldCascadeAllParts()
PUBLIC: Return true if should CASCADE_ALL_PARTS
-
shouldCascadePrivateParts
public boolean shouldCascadePrivateParts()
PUBLIC: Return true if should CASCADE_PRIVATE_PARTS
-
shouldCascadeTree
public boolean shouldCascadeTree()
PUBLIC: Return true if should CASCADE_TREE
-
shouldResetPrimaryKey
public boolean shouldResetPrimaryKey()
PUBLIC: Return if the primary key should be reset to null.
-
shouldResetVersion
public boolean shouldResetVersion()
PUBLIC: Return if the version should be reset to null.
-
toStringAdditionalInfo
protected java.lang.String toStringAdditionalInfo()
INTERNAL:- Overrides:
toStringAdditionalInfoin classCoreAttributeGroup<org.eclipse.persistence.internal.queries.AttributeItem,ClassDescriptor>
-
addAttribute
public void addAttribute(java.lang.String attributeNameOrPath, CoreAttributeGroup group)Description copied from class:CoreAttributeGroupAdd a basic attribute or nested attribute with each String representing an attribute on the path to what needs to be included in the AttributeGroup.Example:
group.addAttribute("firstName", group1);Note that existing group corresponding to attributeNameOrPath will be overridden with the passed group.
group.addAttribute("manager.address", group2);- Overrides:
addAttributein classCoreAttributeGroup<org.eclipse.persistence.internal.queries.AttributeItem,ClassDescriptor>- Parameters:
attributeNameOrPath- A simple attribute, array or attributes forming a pathgroup- - an AttributeGroup to be added.
-
addAttribute
public void addAttribute(java.lang.String attributeNameOrPath, CopyGroup group)
-
isCopyGroup
public boolean isCopyGroup()
Description copied from class:AttributeGroupINTERNAL: This method is used internally when converting to a copy group.- Overrides:
isCopyGroupin classAttributeGroup- Returns:
-
clone
public CopyGroup clone()
- Overrides:
clonein classAttributeGroup
-
getGroup
public CopyGroup getGroup(java.lang.String attributeNameOrPath)
Returns CopyGroup corresponding to the passed (possibly nested) attribute.- Overrides:
getGroupin classAttributeGroup
-
newGroup
protected CopyGroup newGroup(java.lang.String name, CoreAttributeGroup parent)
Description copied from class:AttributeGroupSubclass may create different types.- Overrides:
newGroupin classAttributeGroup
-
-