Module org.eclipse.persistence.jpa
Class RelationshipAccessor
- java.lang.Object
-
- org.eclipse.persistence.internal.jpa.metadata.ORMetadata
-
- org.eclipse.persistence.internal.jpa.metadata.accessors.MetadataAccessor
-
- org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.MappingAccessor
-
- org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.RelationshipAccessor
-
- Direct Known Subclasses:
CollectionAccessor,ObjectAccessor
public abstract class RelationshipAccessor extends MappingAccessor
INTERNAL: A relational accessor. Key notes: - any metadata mapped from XML to this class must be compared in the equals method. - any metadata mapped from XML to this class must be handled in the merge method. (merging is done at the accessor/mapping level) - any metadata mapped from XML to this class must be initialized in the initXMLObject method. - methods should be preserved in alphabetical order.- Since:
- TopLink EJB 3.0 Reference Implementation
- Author:
- Guy Pelletier
-
-
Field Summary
Fields Modifier and Type Field Description protected MetadataClassm_referenceClass-
Fields inherited from class org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.MappingAccessor
KEY_DOT_NOTATION, m_field, VALUE_DOT_NOTATION
-
Fields inherited from class org.eclipse.persistence.internal.jpa.metadata.ORMetadata
m_project
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedRelationshipAccessor(String xmlElement)INTERNAL:protectedRelationshipAccessor(MetadataAnnotation annotation, MetadataAccessibleObject accessibleObject, ClassAccessor classAccessor)INTERNAL:
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddJoinTableRelationKeyFields(List<JoinColumnMetadata> joinColumns, RelationTableMechanism mechanism, String defaultFieldName, MetadataDescriptor descriptor, boolean isSource)INTERNAL: Add the relation key fields to a many to many mapping.booleanequals(Object objectToCompare)INTERNAL:BatchFetchMetadatagetBatchFetch()INTERNAL: Used for OX mapping.CascadeMetadatagetCascade()INTERNAL: Used for OX mapping.BooleangetCascadeOnDelete()INTERNAL: Used for OX mapping.abstract StringgetDefaultFetchType()INTERNAL:protected DatabaseTablegetDefaultTableForEntityMapKey()INTERNAL: Return the default table to hold the foreign key of a MapKey when and Entity is used as the MapKeyStringgetFetch()INTERNAL: Used for OX mapping.ForeignKeyMetadatagetForeignKey()INTERNAL: Used for OX mapping.List<JoinColumnMetadata>getJoinColumns()INTERNAL: Used for OX mapping.StringgetJoinFetch()INTERNAL: Used for OX mapping.List<JoinFieldMetadata>getJoinFields()INTERNAL: Used for OX mapping.JoinTableMetadatagetJoinTable()INTERNAL: Used for OX mapping.protected JoinTableMetadatagetJoinTableMetadata()INTERNAL: This method will return the join table metadata to be processed with this relationship accessor.protected abstract StringgetLoggingContext()INTERNAL: Return the logging context for this accessor.StringgetMappedBy()INTERNAL: Used for OX mapping.BooleangetNonCacheable()INTERNAL: Used for OX mapping.BooleangetOrphanRemoval()INTERNAL: Used for OX mapping.protected DatabaseMappinggetOwningMapping()INTERNAL: Method to return an owner mapping.BooleangetPrivateOwned()INTERNAL: Used for OX mapping.MetadataDescriptorgetReferenceDescriptor()INTERNAL: Return the reference metadata descriptor for this accessor.MetadataClassgetTargetEntity()INTERNAL: Return the target entity for this accessor.StringgetTargetEntityName()INTERNAL: Used for OX mapping.inthashCode()protected booleanhasJoinTable()INTERNAL: Return true if a join table exists for this accessor (either directly set or through an association override).booleanhasMappedBy()INTERNAL: Return true if this accessor is the non owning side of the relationship, that is, has a mapped by value.voidinitXMLObject(MetadataAccessibleObject accessibleObject, XMLEntityMappings entityMappings)INTERNAL:booleanisCascadeOnDelete()INTERNAL:booleanisLazy()INTERNAL: Return if the accessor should be lazy fetched.booleanisNonCacheable()INTERNAL: Used for OX mapping.protected booleanisOrphanRemoval()INTERNAL: Return true is this relationship employs orphanRemoval.booleanisPrivateOwned()INTERNAL: Used for OX mapping.booleanisValueHolderInterface()INTERNAL: If somehow we are processing a class that was weaved to have value holders, we should ignore the processing of this mapping.voidprocess()INTERNAL: Common validation done by all relationship accessors.protected voidprocessBatchFetch(ForeignReferenceMapping mapping)INTERNAL: Set the batch fetch type on the foreign reference mapping.protected voidprocessCascadeTypes(ForeignReferenceMapping mapping)INTERNAL:protected voidprocessJoinTable(ForeignReferenceMapping mapping, RelationTableMechanism mechanism, JoinTableMetadata joinTable)INTERNAL: Process a MetadataJoinTable.protected voidprocessMappedByRelationTable(RelationTableMechanism ownerMechanism, RelationTableMechanism mechanism)INTERNAL:protected voidprocessOrphanRemoval(ForeignReferenceMapping mapping)INTERNAL: This method should be called for all mappings even though they may not support.protected voidprocessRelationshipMapping(ForeignReferenceMapping mapping)INTERNAL: Process settings common to ForeignReferenceMapping.protected voidsetAccessorMethods(DatabaseMapping mapping)INTERNAL: Set the getter and setter access methods for this accessor.voidsetBatchFetch(BatchFetchMetadata batchFetch)INTERNAL: Used for OX mapping.voidsetCascade(CascadeMetadata cascade)INTERNAL: Used for OX mapping.voidsetCascadeOnDelete(Boolean cascadeOnDelete)INTERNAL: Used for OX mapping.voidsetFetch(String fetch)INTERNAL: Used for OX mapping.voidsetForeignKey(ForeignKeyMetadata foreignKey)INTERNAL: Used for OX mapping.voidsetJoinColumns(List<JoinColumnMetadata> joinColumns)INTERNAL: Used for OX mapping.voidsetJoinFetch(String joinFetch)INTERNAL: Used for OX mapping.voidsetJoinFields(List<JoinFieldMetadata> joinFields)INTERNAL: Used for OX mapping.voidsetJoinTable(JoinTableMetadata joinTable)INTERNAL: Used for OX mapping.voidsetMappedBy(String mappedBy)INTERNAL: Used for OX mapping.voidsetNonCacheable(Boolean noncacheable)INTERNAL: Used for OX mapping.voidsetOrphanRemoval(Boolean orphanRemoval)INTERNAL: Used for OX mapping.voidsetPrivateOwned(Boolean privateOwned)INTERNAL: Used for OX mapping.voidsetTargetEntity(MetadataClass targetEntity)INTERNAL:voidsetTargetEntityName(String targetEntityName)INTERNAL: Used for OX mapping.protected booleanusesIndirection()INTERNAL:-
Methods inherited from class org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.MappingAccessor
addConvert, addConvertMetadata, addFieldNameTranslation, addMapKeyConvert, derivesId, getAnnotation, getAssociationOverrides, getAttributeName, getAttributeOverride, getAttributeOverrides, getAttributeType, getClassAccessor, getColumn, getConverts, getDatabaseField, getEnumerated, getField, getForeignKey, getGetMethodName, getJoinColumns, getJoinColumnsAndValidate, getLob, getMapKey, getMapKeyConverts, getMapKeyReferenceClass, getMapKeyReferenceClassName, getMapKeyReferenceClassWithGenerics, getMapping, getOwningDescriptor, getOwningDescriptors, getRawClass, getRawClassWithGenerics, getReferenceAccessors, getReferenceClass, getReferenceClassFromGeneric, getReferenceClassName, getReferenceClassWithGenerics, getReferenceDatabaseTable, getSetMethodName, getTemporal, hasAttributeOverride, hasAttributeType, hasEnumerated, hasLob, hasMapKey, hasReturnInsert, hasReturnUpdate, hasTemporal, initXMLMappingAccessor, isAnnotationPresent, isBasic, isBasicCollection, isBasicMap, isCollectionAccessor, isDerivedIdClass, isDirectCollection, isDirectEmbeddableCollection, isEmbedded, isEmbeddedId, isEnumerated, isId, isJson, isLob, isManyToMany, isManyToOne, isMapAccessor, isMappedKeyMapAccessor, isMultitenantId, isOneToMany, isOneToOne, isPrimitiveWrapperClass, isProcessed, isRelationship, isSerialized, isTemporal, isTimeClass, isTransient, isUUID, isValidJsonType, isValidSerializedType, isVariableOneToOne, processAssociationOverride, processAssociationOverrides, processAttributeOverrides, processContainerPolicyAndIndirection, processConvert, processConverts, processDirectMapKeyClass, processEmbeddableMapKeyClass, processEntityMapKeyClass, processEnumerated, processForeignKeyRelationship, processIndirection, processJoinFetch, processJson, processLob, processMapKeyClass, processMappingConverter, processMappingKeyConverter, processMappingValueConverter, processProperties, processProperty, processReturnInsert, processReturnInsertAndUpdate, processReturnUpdate, processSerialized, processSerialized, processTemporal, processUUID, setAttributeType, setClassAccessor, setField, setIndirectionPolicy, setMapping, setOverrideMapping, setTemporal, toString, updatePrimaryKeyField, usesFieldAccess, usesPropertyAccess, usesVirtualAccess
-
Methods inherited from class org.eclipse.persistence.internal.jpa.metadata.accessors.MetadataAccessor
getAccess, getAccessibleObject, getAccessMethods, getAnnotatedElement, getAnnotatedElementName, getAnnotation, getConverters, getDefaultAttributeName, getDescriptor, getDescriptorJavaClass, getHashPartitioning, getIdentifier, getJavaClass, getJavaClassName, getName, getObjectTypeConverters, getPartitioned, getPartitioning, getPinnedPartitioning, getProperties, getRangePartitioning, getReferencedField, getReferencedField, getReplicationPartitioning, getRoundRobinPartitioning, getSerializedConverters, getStructConverters, getTypeConverters, getUnionPartitioning, getUpperCaseShortJavaClassName, getValue, getValue, getValuePartitioning, hasAccess, hasAccessMethods, initAccess, initXMLAccessor, isAnnotationPresent, merge, processConverters, processCustomConverters, processObjectTypeConverters, processPartitioned, processPartitioning, processPrimaryKeyJoinColumns, processSerializedConverters, processStructConverters, processTable, processTypeConverters, setAccess, setAccessMethods, setConverters, setDescriptor, setHashPartitioning, setName, setObjectTypeConverters, setPartitioned, setPartitioning, setPinnedPartitioning, setProperties, setRangePartitioning, setReplicationPartitioning, setRoundRobinPartitioning, setSerializedConverters, setStructConverters, setTypeConverters, setUnionPartitioning, setValuePartitioning
-
Methods inherited from class org.eclipse.persistence.internal.jpa.metadata.ORMetadata
getAccessibleObjectName, getAnnotation, getBoxedType, getDatabaseTypeEnum, getEntityMappings, getFullyQualifiedClassName, getJavaClass, getJavaClassName, getLoader, getLocation, getLogger, getMetadataClass, getMetadataClass, getMetadataClass, getMetadataFactory, getName, getPrimitiveClassForName, getProject, getText, getXMLElement, hasIdentifier, hasText, initXMLClassName, initXMLObject, initXMLObjects, initXMLTextObject, loadedFromAnnotation, loadedFromEclipseLinkXML, loadedFromXML, mergeORObjectLists, mergeORObjects, mergeSimpleObjects, reloadEntity, reloadMappedSuperclass, setAccessibleObject, setEntityMappings, setFieldName, setFieldName, setProject, shouldOverride, valuesMatch, valuesMatch
-
-
-
-
Field Detail
-
m_referenceClass
protected MetadataClass m_referenceClass
-
-
Constructor Detail
-
RelationshipAccessor
protected RelationshipAccessor(String xmlElement)
INTERNAL:
-
RelationshipAccessor
protected RelationshipAccessor(MetadataAnnotation annotation, MetadataAccessibleObject accessibleObject, ClassAccessor classAccessor)
INTERNAL:
-
-
Method Detail
-
addJoinTableRelationKeyFields
protected void addJoinTableRelationKeyFields(List<JoinColumnMetadata> joinColumns, RelationTableMechanism mechanism, String defaultFieldName, MetadataDescriptor descriptor, boolean isSource)
INTERNAL: Add the relation key fields to a many to many mapping.
-
equals
public boolean equals(Object objectToCompare)
INTERNAL:- Overrides:
equalsin classMappingAccessor
-
hashCode
public int hashCode()
- Overrides:
hashCodein classMappingAccessor
-
getBatchFetch
public BatchFetchMetadata getBatchFetch()
INTERNAL: Used for OX mapping.
-
getCascadeOnDelete
public Boolean getCascadeOnDelete()
INTERNAL: Used for OX mapping.
-
getCascade
public CascadeMetadata getCascade()
INTERNAL: Used for OX mapping.
-
getDefaultFetchType
public abstract String getDefaultFetchType()
INTERNAL:- Overrides:
getDefaultFetchTypein classMappingAccessor
-
getDefaultTableForEntityMapKey
protected DatabaseTable getDefaultTableForEntityMapKey()
INTERNAL: Return the default table to hold the foreign key of a MapKey when and Entity is used as the MapKey- Overrides:
getDefaultTableForEntityMapKeyin classMappingAccessor
-
getFetch
public String getFetch()
INTERNAL: Used for OX mapping.
-
getForeignKey
public ForeignKeyMetadata getForeignKey()
INTERNAL: Used for OX mapping.
-
getJoinColumns
public List<JoinColumnMetadata> getJoinColumns()
INTERNAL: Used for OX mapping.
-
getJoinFields
public List<JoinFieldMetadata> getJoinFields()
INTERNAL: Used for OX mapping.
-
getJoinFetch
public String getJoinFetch()
INTERNAL: Used for OX mapping.
-
getJoinTable
public JoinTableMetadata getJoinTable()
INTERNAL: Used for OX mapping.
-
getJoinTableMetadata
protected JoinTableMetadata getJoinTableMetadata()
INTERNAL: This method will return the join table metadata to be processed with this relationship accessor. It will first check for a join table from an association override, followed by a join table defined directly on the accessor. If neither is present, a join table metadata is defaulted.
-
getLoggingContext
protected abstract String getLoggingContext()
INTERNAL: Return the logging context for this accessor.
-
getMappedBy
public String getMappedBy()
INTERNAL: Used for OX mapping.
-
getNonCacheable
public Boolean getNonCacheable()
INTERNAL: Used for OX mapping.
-
getOrphanRemoval
public Boolean getOrphanRemoval()
INTERNAL: Used for OX mapping.
-
getOwningMapping
protected DatabaseMapping getOwningMapping()
INTERNAL: Method to return an owner mapping. It will tell the owner class to process itself if it hasn't already done so. Assumes that a mapped by value has been specified and that a check against mappedBy has been done.
-
getPrivateOwned
public Boolean getPrivateOwned()
INTERNAL: Used for OX mapping.
-
getReferenceDescriptor
public MetadataDescriptor getReferenceDescriptor()
INTERNAL: Return the reference metadata descriptor for this accessor. This method does additional checks to make sure that the target entity is indeed an entity class.- Overrides:
getReferenceDescriptorin classMappingAccessor
-
getTargetEntity
public MetadataClass getTargetEntity()
INTERNAL: Return the target entity for this accessor.
-
getTargetEntityName
public String getTargetEntityName()
INTERNAL: Used for OX mapping.
-
hasJoinTable
protected boolean hasJoinTable()
INTERNAL: Return true if a join table exists for this accessor (either directly set or through an association override).
-
hasMappedBy
public boolean hasMappedBy()
INTERNAL: Return true if this accessor is the non owning side of the relationship, that is, has a mapped by value.
-
initXMLObject
public void initXMLObject(MetadataAccessibleObject accessibleObject, XMLEntityMappings entityMappings)
INTERNAL:- Overrides:
initXMLObjectin classMappingAccessor
-
isCascadeOnDelete
public boolean isCascadeOnDelete()
INTERNAL:
-
isLazy
public boolean isLazy()
INTERNAL: Return if the accessor should be lazy fetched.
-
isNonCacheable
public boolean isNonCacheable()
INTERNAL: Used for OX mapping.
-
isOrphanRemoval
protected boolean isOrphanRemoval()
INTERNAL: Return true is this relationship employs orphanRemoval.
-
isPrivateOwned
public boolean isPrivateOwned()
INTERNAL: Used for OX mapping.
-
isValueHolderInterface
public boolean isValueHolderInterface()
INTERNAL: If somehow we are processing a class that was weaved to have value holders, we should ignore the processing of this mapping.
-
process
public void process()
INTERNAL: Common validation done by all relationship accessors.- Specified by:
processin classMetadataAccessor
-
processBatchFetch
protected void processBatchFetch(ForeignReferenceMapping mapping)
INTERNAL: Set the batch fetch type on the foreign reference mapping.
-
processCascadeTypes
protected void processCascadeTypes(ForeignReferenceMapping mapping)
INTERNAL:
-
processJoinTable
protected void processJoinTable(ForeignReferenceMapping mapping, RelationTableMechanism mechanism, JoinTableMetadata joinTable)
INTERNAL: Process a MetadataJoinTable.
-
processMappedByRelationTable
protected void processMappedByRelationTable(RelationTableMechanism ownerMechanism, RelationTableMechanism mechanism)
INTERNAL:
-
processOrphanRemoval
protected void processOrphanRemoval(ForeignReferenceMapping mapping)
INTERNAL: This method should be called for all mappings even though they may not support. The reason is that we want to log a message for those mappings that try to employ a private owned setting when it is not supported on their mapping. Order of checking is as follows: 1 - check for orphanRemoval first. Through meta data, this can only be true for 1-1, 1-M and V1-1 2 - check for isPrivateOwned. Do no check the variable directly as the isPrivateOwned method is overridden in those classes that do not support it (to check if the user decorated the mapping with a private owned and log a warning message that we are ignoring it.)
-
processRelationshipMapping
protected void processRelationshipMapping(ForeignReferenceMapping mapping)
INTERNAL: Process settings common to ForeignReferenceMapping.
-
setAccessorMethods
protected void setAccessorMethods(DatabaseMapping mapping)
INTERNAL: Set the getter and setter access methods for this accessor.- Overrides:
setAccessorMethodsin classMappingAccessor
-
setBatchFetch
public void setBatchFetch(BatchFetchMetadata batchFetch)
INTERNAL: Used for OX mapping.
-
setCascade
public void setCascade(CascadeMetadata cascade)
INTERNAL: Used for OX mapping.
-
setCascadeOnDelete
public void setCascadeOnDelete(Boolean cascadeOnDelete)
INTERNAL: Used for OX mapping.
-
setFetch
public void setFetch(String fetch)
INTERNAL: Used for OX mapping.
-
setForeignKey
public void setForeignKey(ForeignKeyMetadata foreignKey)
INTERNAL: Used for OX mapping.
-
setJoinColumns
public void setJoinColumns(List<JoinColumnMetadata> joinColumns)
INTERNAL: Used for OX mapping.
-
setJoinFields
public void setJoinFields(List<JoinFieldMetadata> joinFields)
INTERNAL: Used for OX mapping.
-
setJoinFetch
public void setJoinFetch(String joinFetch)
INTERNAL: Used for OX mapping.
-
setJoinTable
public void setJoinTable(JoinTableMetadata joinTable)
INTERNAL: Used for OX mapping.
-
setMappedBy
public void setMappedBy(String mappedBy)
INTERNAL: Used for OX mapping.
-
setNonCacheable
public void setNonCacheable(Boolean noncacheable)
INTERNAL: Used for OX mapping.
-
setOrphanRemoval
public void setOrphanRemoval(Boolean orphanRemoval)
INTERNAL: Used for OX mapping.
-
setPrivateOwned
public void setPrivateOwned(Boolean privateOwned)
INTERNAL: Used for OX mapping.
-
setTargetEntity
public void setTargetEntity(MetadataClass targetEntity)
INTERNAL:
-
setTargetEntityName
public void setTargetEntityName(String targetEntityName)
INTERNAL: Used for OX mapping.
-
usesIndirection
protected boolean usesIndirection()
INTERNAL:- Overrides:
usesIndirectionin classMappingAccessor- See Also:
RelationshipAccessor,DirectAccessor
-
-