Class ObjectBuilder

    • Field Detail

      • fieldsMap

        protected Map<DatabaseField,​DatabaseField> fieldsMap
        Used to maintain identity on the field objects. Ensure they get the correct index/type.
      • primaryKeyMappings

        protected List<DatabaseMapping> primaryKeyMappings
        Mapping for the primary key fields.
      • primaryKeyClassifications

        protected List<Class> primaryKeyClassifications
        The types for the primary key fields, in same order as descriptor's primary key fields.
      • nonPrimaryKeyMappings

        protected transient List<DatabaseMapping> nonPrimaryKeyMappings
        All mapping other than primary key mappings.
      • primaryKeyExpression

        protected transient Expression primaryKeyExpression
        Expression for querying an object by primary key.
      • joinedAttributes

        protected List<DatabaseMapping> joinedAttributes
        PERF: Cache mapping that use joining.
      • batchFetchedAttributes

        protected List<DatabaseMapping> batchFetchedAttributes
        PERF: Cache mapping that use batch fetching.
      • hasInBatchFetchedAttribute

        protected boolean hasInBatchFetchedAttribute
        PERF: Cache mapping that use batch fetching.
      • cloningMappings

        protected List<DatabaseMapping> cloningMappings
        PERF: Cache mappings that require cloning.
      • eagerMappings

        protected List<DatabaseMapping> eagerMappings
        PERF: Cache mappings that are eager loaded.
      • relationshipMappings

        protected List<DatabaseMapping> relationshipMappings
        PERF: Cache relationship mappings.
      • isSimple

        protected boolean isSimple
        PERF: Cache if is a simple mapping, all direct.
      • hasWrapperPolicy

        protected boolean hasWrapperPolicy
        PERF: Cache if has a wrapper policy.
      • mayHaveNullInPrimaryKey

        protected boolean mayHaveNullInPrimaryKey
        indicates whether part of primary key is unmapped - may happen only in case AggregateObject or AggregateCollection descriptor.
      • lockAttribute

        protected String lockAttribute
        attribute name corresponding to optimistic lock field, set only if optimistic locking is used
      • shouldKeepRow

        protected boolean shouldKeepRow
        PERF: is there a mapping using indirection (could be nested in aggregate(s)), or any other reason to keep row after the object has been created. Used by ObjectLevelReadQuery ResultSetAccessOptimization.
      • hasCacheIndexesInSopObject

        protected boolean hasCacheIndexesInSopObject
        PERF: is there an cache index field that's would not be selected by SOP query. Ignored unless descriptor uses SOP and CachePolicy has cache indexes.
    • Constructor Detail

    • Method Detail

      • createRecord

        public AbstractRecord createRecord​(int size,
                                           AbstractSession session)
        Create a new row/record for the object builder. This allows subclasses to define different record types.
      • createRecordForPKExtraction

        protected AbstractRecord createRecordForPKExtraction​(int size,
                                                             AbstractSession session)
        Create a new row/record for the object builder. This allows subclasses to define different record types. This will typically be called when a record will be used for temporarily holding on to primary key fields.
      • addPrimaryKeyForNonDefaultTable

        public void addPrimaryKeyForNonDefaultTable​(AbstractRecord databaseRow)
        Add the primary key and its value to the Record for all the non default tables. This method is used while writing into the multiple tables.
      • addPrimaryKeyForNonDefaultTable

        public void addPrimaryKeyForNonDefaultTable​(AbstractRecord databaseRow,
                                                    Object object,
                                                    AbstractSession session)
        Add the primary key and its value to the Record for all the non default tables. This method is used while writing into the multiple tables.
      • clearPrimaryKey

        public void clearPrimaryKey​(Object object)
        Clear any primary key cache data in the object.
      • assignReturnRow

        public void assignReturnRow​(Object object,
                                    AbstractSession writeSession,
                                    AbstractRecord row,
                                    ObjectChangeSet changeSet)
                             throws DatabaseException
        Assign the fields in the row back into the object. This is used by returning, as well as events and version locking. If not null changeSet must correspond to object. changeSet is updated with all of the field values in the row.
        Throws:
        DatabaseException
      • assignReturnValueForField

        public void assignReturnValueForField​(Object object,
                                              ReadObjectQuery query,
                                              AbstractRecord row,
                                              DatabaseField field,
                                              Collection handledMappings,
                                              ObjectChangeSet changeSet)
        Assign the field value from the row to the object for all the mappings using field (read or write). If not null changeSet must correspond to object. changeSet is updated with all of the field values in the row.
      • assignSequenceNumber

        public Object assignSequenceNumber​(Object object,
                                           AbstractSession writeSession)
                                    throws DatabaseException
        INTERNAL: Update the object primary key by fetching a new sequence number from the accessor. This assume the uses sequence numbers check has already been done.
        Returns:
        the sequence value or null if not assigned.
        Throws:
        DatabaseException - - an error has occurred on the database.
      • assignSequenceNumber

        public Object assignSequenceNumber​(WriteObjectQuery writeQuery)
                                    throws DatabaseException
        INTERNAL: Update the writeQuery's object primary key by fetching a new sequence number from the accessor. This assume the uses sequence numbers check has already been done. Adds the assigned sequence value to writeQuery's modify row. If object has a changeSet then sets sequence value into change set as an Id adds it also to object's change set in a ChangeRecord if required.
        Returns:
        the sequence value or null if not assigned.
        Throws:
        DatabaseException - - an error has occurred on the database.
      • assignSequenceNumber

        public Object assignSequenceNumber​(WriteObjectQuery writeQuery,
                                           Object sequenceValue)
                                    throws DatabaseException
        INTERNAL: Update the writeQuery's object primary key by fetching a new sequence number from the accessor. This assume the uses sequence numbers check has already been done. Adds the assigned sequence value to writeQuery's modify row. If object has a changeSet then sets sequence value into change set as an Id adds it also to object's change set in a ChangeRecord if required.
        Returns:
        the sequence value or null if not assigned.
        Throws:
        DatabaseException - - an error has occurred on the database.
      • assignSequenceNumber

        protected Object assignSequenceNumber​(Object object,
                                              Object sequenceValue,
                                              AbstractSession writeSession,
                                              WriteObjectQuery writeQuery)
                                       throws DatabaseException
        INTERNAL: Update the object primary key by fetching a new sequence number from the accessor. This assume the uses sequence numbers check has already been done. Adds the assigned sequence value to writeQuery's modify row. If object has a changeSet then sets sequence value into change set as an Id adds it also to object's change set in a ChangeRecord if required.
        Returns:
        the sequence value or null if not assigned.
        Throws:
        DatabaseException - - an error has occurred on the database.
      • buildAttributesIntoObjectSOP

        protected boolean buildAttributesIntoObjectSOP​(Object domainObject,
                                                       CacheKey cacheKey,
                                                       AbstractRecord databaseRow,
                                                       ObjectBuildingQuery query,
                                                       JoinedAttributeManager joinManager,
                                                       FetchGroup executionFetchGroup,
                                                       boolean forRefresh,
                                                       AbstractSession targetSession)
                                                throws DatabaseException
        Each mapping is recursed to assign values from the Record to the attributes in the domain object. Should not be called unless (this.descriptor.hasSerializedObjectPolicy() && query.shouldUseSerializedObjectPolicy()) This method populates the object only in if some mappings potentially should be read using sopObject and other mappings - not using it. That happens when the row has been just read from the database and potentially has serialized object still in deserialized bits as a field value. Note that domainObject == sopObject is the same case, but (because domainObject has to be set into cache beforehand) extraction of sopObject from bit was done right before this method is called. Alternative situation is processing an empty row that has been created by foreign reference mapping and holds nothing but sopObject (which is an attribute of the original sopObject) - this case falls through to buildAttributesIntoObject. If attempt to deserialize sopObject from bits has failed, but SOP was setup to allow recovery (all mapped all fields/value mapped to the object were read, not just those excluded from SOP) then fall through to buildAttributesIntoObject. Nothing should be done if sopObject is not null, but domainObject != sopObject: the only way to get into this case should be with original query not maintaining cache, through a back reference to the original object, which is already being built (or has been built).
        Returns:
        whether the object has been populated with attributes, if not then buildAttributesIntoObject should be called.
        Throws:
        DatabaseException
      • buildBackupClone

        public Object buildBackupClone​(Object clone,
                                       UnitOfWorkImpl unitOfWork)
        Returns the backup clone of the specified object. This is called only from unit of work. The clone sent as parameter is always a working copy from the unit of work.
      • buildDeleteExpression

        public Expression buildDeleteExpression​(DatabaseTable table,
                                                AbstractRecord row,
                                                boolean usesOptimisticLocking)
        Build and return the expression to use as the where clause to delete an object. The row is passed to allow the version number to be extracted from it. If called with usesOptimisticLocking==true the caller should make sure that descriptor uses optimistic locking policy.
      • buildExpressionFromExample

        public Expression buildExpressionFromExample​(Object queryObject,
                                                     QueryByExamplePolicy policy,
                                                     Expression expressionBuilder,
                                                     Map processedObjects,
                                                     AbstractSession session)
        INTERNAL: This method is used when Query By Example is used. Going through the mappings one by one, this method calls the specific buildExpression method corresponding to the type of mapping. It then generates a complete Expression by joining the individual Expressions.
      • buildObject

        public Object buildObject​(ObjectLevelReadQuery query,
                                  AbstractRecord databaseRow)
        Return an instance of the receivers javaClass. Set the attributes of an instance from the values stored in the database row.
      • instantiateEagerMappings

        public void instantiateEagerMappings​(Object object,
                                             AbstractSession session)
        Force instantiation to any eager mappings.
      • loadAll

        public void loadAll​(Object object,
                            AbstractSession session)
        Force instantiation of all indirections.
      • buildObjectsInto

        public Object buildObjectsInto​(ReadAllQuery query,
                                       List databaseRows,
                                       Object domainObjects)
        Return a container which contains the instances of the receivers javaClass. Set the fields of the instance to the values stored in the database rows.
      • buildObjectsFromResultSetInto

        public Object buildObjectsFromResultSetInto​(ReadAllQuery query,
                                                    ResultSet resultSet,
                                                    Vector fields,
                                                    DatabaseField[] fieldsArray,
                                                    Object domainObjects)
                                             throws SQLException
        Version of buildObjectsInto method that takes call instead of rows. Return a container which contains the instances of the receivers javaClass. Set the fields of the instance to the values stored in the result set.
        Throws:
        SQLException
      • buildObjectsFromCursorInto

        public Object buildObjectsFromCursorInto​(ReadAllQuery query,
                                                 List databaseRows,
                                                 Object domainObjects)
        Return a container which contains the instances of the receivers javaClass. Set the fields of the instance to the values stored in the database rows.
      • buildPrimaryKeyExpressionFromKeys

        public Expression buildPrimaryKeyExpressionFromKeys​(Object primaryKey,
                                                            AbstractSession session)
        Build the primary key expression from the specified primary key values.
      • buildPrimaryKeyExpressionFromObject

        public Expression buildPrimaryKeyExpressionFromObject​(Object domainObject,
                                                              AbstractSession session)
        Build the primary key expression from the specified domain object.
      • buildRowForShallowInsert

        public AbstractRecord buildRowForShallowInsert​(Object object,
                                                       AbstractSession session)
        Build the row representation of the object for update. The row built does not contain entries for uninstantiated attributes.
      • buildRowForShallowInsert

        public AbstractRecord buildRowForShallowInsert​(AbstractRecord databaseRow,
                                                       Object object,
                                                       AbstractSession session)
        Build the row representation of the object for update. The row built does not contain entries for uninstantiated attributes.
      • buildRowForUpdateAfterShallowInsert

        public AbstractRecord buildRowForUpdateAfterShallowInsert​(Object object,
                                                                  AbstractSession session,
                                                                  DatabaseTable table)
        Build the row representation of the object that contains only the fields nullified by shallow insert.
      • buildRowForUpdateBeforeShallowDelete

        public AbstractRecord buildRowForUpdateBeforeShallowDelete​(Object object,
                                                                   AbstractSession session,
                                                                   DatabaseTable table)
        Build the row representation of the object that contains only the fields nullified by shallow insert, with all values set to null.
      • buildRowForUpdateBeforeShallowDelete

        public AbstractRecord buildRowForUpdateBeforeShallowDelete​(AbstractRecord databaseRow,
                                                                   Object object,
                                                                   AbstractSession session,
                                                                   DatabaseTable table)
        Build the row representation of the object that contains only the fields nullified by shallow insert, with all values set to null.
      • buildRowForTranslation

        public AbstractRecord buildRowForTranslation​(Object object,
                                                     AbstractSession session)
        Build the row representation of an object. The row built is used only for translations for the expressions in the expression framework.
      • buildRowForUpdate

        public AbstractRecord buildRowForUpdate​(WriteObjectQuery query)
        Build the row representation of the object for update. The row built does not contain entries for unchanged attributes.
      • buildRowForUpdate

        public AbstractRecord buildRowForUpdate​(AbstractRecord databaseRow,
                                                WriteObjectQuery query)
        Build into the row representation of the object for update. The row does not contain entries for unchanged attributes.
      • buildRowForUpdateWithChangeSet

        public AbstractRecord buildRowForUpdateWithChangeSet​(WriteObjectQuery query)
        Build the row representation of the object for update. The row built does not contain entries for uninstantiated attributes.
      • buildTemplateInsertRow

        public AbstractRecord buildTemplateInsertRow​(AbstractSession session)
        Build the row of all of the fields used for insertion.
      • trimFieldsForInsert

        public void trimFieldsForInsert​(AbstractSession session,
                                        AbstractRecord databaseRow)
        INTERNAL Remove a potential sequence number field and invoke the ReturningPolicy trimModifyRowsForInsert method
      • buildTemplateUpdateRow

        public AbstractRecord buildTemplateUpdateRow​(AbstractSession session)
        Build the row representation of the object for update. The row built does not contain entries for uninstantiated attributes.
      • buildUpdateExpression

        public Expression buildUpdateExpression​(DatabaseTable table,
                                                AbstractRecord transactionRow,
                                                AbstractRecord modifyRow)
        Build and return the expression to use as the where clause to an update object. The row is passed to allow the version number to be extracted from it.
      • buildAttributesIntoShallowObject

        public void buildAttributesIntoShallowObject​(Object original,
                                                     AbstractRecord databaseRow,
                                                     ObjectBuildingQuery query)
                                              throws DatabaseException,
                                                     QueryException
        INTERNAL: For reading through the write connection when in transaction, We need a partially populated original, so that we can build a clone using the copy policy, even though we can't put this original in the shared cache yet; just build a shallow original (i.e. just enough to copy over the primary key and some direct attributes) and keep it on the UOW.
        Throws:
        DatabaseException
        QueryException
      • buildAttributesIntoWorkingCopyCloneSOP

        protected boolean buildAttributesIntoWorkingCopyCloneSOP​(Object clone,
                                                                 CacheKey sharedCacheKey,
                                                                 ObjectBuildingQuery query,
                                                                 JoinedAttributeManager joinManager,
                                                                 AbstractRecord databaseRow,
                                                                 UnitOfWorkImpl unitOfWork,
                                                                 boolean forRefresh)
                                                          throws DatabaseException
        For reading through the write connection when in transaction, populate the clone directly from the database row. Should not be called unless (this.descriptor.hasSerializedObjectPolicy() && query.shouldUseSerializedObjectPolicy()) This method populates the object only in if some mappings potentially should be read using sopObject and other mappings - not using it. That happens when the row has been just read from the database and potentially has serialized object still in deserialized bits as a field value. Note that clone == sopObject is the same case, but (because clone has to be set into cache beforehand) extraction of sopObject from bit was done right before this method is called. If attempt to deserialize sopObject from bits has failed, but SOP was setup to allow recovery (all mapped all fields/value mapped to the object were read, not just those excluded from SOP) then fall through to buildAttributesIntoWorkingCopyClone. Nothing should be done if sopObject is not null, but clone != sopObject: the only way to get into this case should be with original query not maintaining cache, through a back reference to the original object, which is already being built (or has been built).
        Returns:
        whether the object has been populated with attributes, if not then buildAttributesIntoWorkingCopyClone should be called.
        Throws:
        DatabaseException
      • clone

        public Object clone()
        Returns a clone of itself.
        Overrides:
        clone in class Object
      • cascadePerformRemove

        public void cascadePerformRemove​(Object object,
                                         UnitOfWorkImpl uow,
                                         Map visitedObjects)
        INTERNAL: This method is used by the UnitOfWork to cascade registration of new objects. It may raise exceptions as described in the EJB3 specification
      • cascadePerformRemovePrivateOwnedObjectFromChangeSet

        public void cascadePerformRemovePrivateOwnedObjectFromChangeSet​(Object object,
                                                                        UnitOfWorkImpl uow,
                                                                        Map visitedObjects)
        INTERNAL: This method is used to iterate over the specified object's mappings and cascade remove orphaned private owned objects from the UnitOfWorkChangeSet and IdentityMap.
      • cacheForeignKeyValues

        public void cacheForeignKeyValues​(AbstractRecord databaseRecord,
                                          CacheKey cacheKey,
                                          AbstractSession session)
        INTERNAL: This method is used to store the FK values used for this mapping in the cachekey. This is used when the mapping is protected but we have retrieved the fk values and will cache them for use when the entity is cloned.
      • cacheForeignKeyValues

        public void cacheForeignKeyValues​(Object source,
                                          CacheKey cacheKey,
                                          ClassDescriptor descriptor,
                                          AbstractSession session)
        INTERNAL: This method is used to store the FK values used for this mapping in the cachekey. This is used when the mapping is protected but we have retrieved the fk values and will cache them for use when the entity is cloned.
      • cascadeDiscoverAndPersistUnregisteredNewObjects

        public void cascadeDiscoverAndPersistUnregisteredNewObjects​(Object object,
                                                                    Map newObjects,
                                                                    Map unregisteredExistingObjects,
                                                                    Map visitedObjects,
                                                                    UnitOfWorkImpl uow,
                                                                    Set cascadeErrors)
        INTERNAL: Cascade discover and persist new objects during commit. It may raise exceptions as described in the EJB3 specification
      • cascadeRegisterNewForCreate

        public void cascadeRegisterNewForCreate​(Object object,
                                                UnitOfWorkImpl uow,
                                                Map visitedObjects)
        INTERNAL: This method is used by the UnitOfWork to cascade registration of new objects. It may raise exceptions as described in the EJB3 specification
      • compareObjects

        public boolean compareObjects​(Object firstObject,
                                      Object secondObject,
                                      AbstractSession session)
        Compares the two specified objects
      • copyInto

        public void copyInto​(Object source,
                             Object target,
                             boolean cloneOneToOneValueHolders)
        Copy each attribute from one object into the other.
      • copyInto

        public void copyInto​(Object source,
                             Object target)
        Copy each attribute from one object into the other.
      • copyObject

        public Object copyObject​(Object original,
                                 CopyGroup copyGroup)
        Return a copy of the object. This is NOT used for unit of work but for templatizing an object. The depth and primary key reseting are passed in.
      • createObjectChangeSet

        public ObjectChangeSet createObjectChangeSet​(Object clone,
                                                     UnitOfWorkChangeSet uowChangeSet,
                                                     AbstractSession session)
        INTERNAL: Used by the ObjectBuilder to create an ObjectChangeSet for the specified clone object.
        Parameters:
        clone - the object to convert to a changeSet.
        uowChangeSet - the owner of this changeSet.
        Returns:
        ObjectChangeSet the newly created changeSet representing the clone object
      • createObjectChangeSet

        public ObjectChangeSet createObjectChangeSet​(Object clone,
                                                     UnitOfWorkChangeSet uowChangeSet,
                                                     boolean isNew,
                                                     AbstractSession session)
        INTERNAL: Used by the ObjectBuilder to create an ObjectChangeSet for the specified clone object.
        Parameters:
        clone - the object to convert to a changeSet.
        uowChangeSet - the owner of this changeSet.
        isNew - signifies if the clone object is a new object.
        Returns:
        ObjectChangeSet the newly created changeSet representing the clone object
      • createObjectChangeSet

        public ObjectChangeSet createObjectChangeSet​(Object clone,
                                                     UnitOfWorkChangeSet uowChangeSet,
                                                     boolean isNew,
                                                     boolean assignPrimaryKeyIfExisting,
                                                     AbstractSession session)
        INTERNAL: Used by the ObjectBuilder to create an ObjectChangeSet for the specified clone object.
        Parameters:
        clone - the object to convert to a changeSet.
        uowChangeSet - the owner of this changeSet.
        isNew - signifies if the clone object is a new object.
        assignPrimaryKeyIfExisting - signifies if the primary key of the change set should be updated if existing.
        Returns:
        ObjectChangeSet the newly created changeSet representing the clone object
      • createPrimaryKeyExpression

        public void createPrimaryKeyExpression​(AbstractSession session)
        Creates and stores primary key expression.
      • extractPrimaryKeyFromExpression

        public Object extractPrimaryKeyFromExpression​(boolean requiresExactMatch,
                                                      Expression expression,
                                                      AbstractRecord translationRow,
                                                      AbstractSession session)
        Return the row with primary keys and their values from the given expression.
      • isPrimaryKeyExpression

        public boolean isPrimaryKeyExpression​(boolean requiresExactMatch,
                                              Expression expression,
                                              AbstractSession session)
        Return if the expression is by primary key.
      • extractPrimaryKeyFromObject

        public Object extractPrimaryKeyFromObject​(Object domainObject,
                                                  AbstractSession session,
                                                  boolean shouldReturnNullIfNull)
        Extract primary key attribute values from the domainObject.
      • extractPrimaryKeyFromRow

        public Object extractPrimaryKeyFromRow​(AbstractRecord databaseRow,
                                               AbstractSession session)
        Extract primary key values from the specified row. null is returned if the row does not contain the key.
      • extractPrimaryKeyRowFromObject

        public AbstractRecord extractPrimaryKeyRowFromObject​(Object domainObject,
                                                             AbstractSession session)
        Extract primary key attribute values from the domainObject.
      • fixObjectReferences

        public void fixObjectReferences​(Object object,
                                        Map objectDescriptors,
                                        Map processedObjects,
                                        ObjectLevelReadQuery query,
                                        DistributedSession session)
        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.
      • getBaseChangeRecordForField

        public ChangeRecord getBaseChangeRecordForField​(ObjectChangeSet objectChangeSet,
                                                        Object object,
                                                        DatabaseField databaseField,
                                                        AbstractSession session)
        Return the base ChangeRecord for the given DatabaseField. The object and all its relevant aggregates must exist. The returned ChangeRecord is either DirectToFieldChangeRecord or TransformationMappingChangeRecord, or null.
      • getBaseMappingForField

        public DatabaseMapping getBaseMappingForField​(DatabaseField databaseField)
        Return the base mapping for the given DatabaseField.
      • getBaseValueForField

        public Object getBaseValueForField​(DatabaseField databaseField,
                                           Object domainObject)
        Return the base value that is mapped to for given field.
      • getDescriptor

        public ClassDescriptor getDescriptor()
        Return the descriptor
      • getFieldClassification

        public Class getFieldClassification​(DatabaseField fieldToClassify)
                                     throws DescriptorException
        INTERNAL: Return the classification for the field contained in the mapping. This is used to convert the row value to a consistent java value.
        Throws:
        DescriptorException
      • getFieldForQueryKeyName

        public DatabaseField getFieldForQueryKeyName​(String name)
        Return the field used for the query key name.
      • getFieldsMap

        public Map<DatabaseField,​DatabaseField> getFieldsMap()
        Return the fields map. Used to maintain identity on the field objects. Ensure they get the correct index/type.
      • setFieldsMap

        protected void setFieldsMap​(Map fieldsMap)
        Return the fields map. Used to maintain identity on the field objects. Ensure they get the correct index/type.
      • getCloningMappings

        public List<DatabaseMapping> getCloningMappings()
        PERF: Return all mappings that require cloning. This allows for simple directs to be avoided when using clone copying.
      • isSimple

        public boolean isSimple()
        PERF: Return if the descriptor has no complex mappings, all direct.
      • getRelationshipMappings

        public List<DatabaseMapping> getRelationshipMappings()
        PERF: Return all relationship mappings.
      • getEagerMappings

        public List<DatabaseMapping> getEagerMappings()
        PERF: Return all mappings that are eager loaded (but use indirection). This allows for eager mappings to still benefit from indirection for locking and change tracking.
      • getJoinedAttributes

        public List<DatabaseMapping> getJoinedAttributes()
        Answers the attributes which are always joined to the original query on reads.
      • getBatchFetchedAttributes

        public List<DatabaseMapping> getBatchFetchedAttributes()
        Return the mappings that are always batch fetched.
      • getSequenceMapping

        public AbstractDirectMapping getSequenceMapping()
        PERF: Return the sequence mapping.
      • setSequenceMapping

        public void setSequenceMapping​(AbstractDirectMapping sequenceMapping)
        PERF: Set the sequence mapping.
      • hasJoinedAttributes

        public boolean hasJoinedAttributes()
        Answers if any attributes are to be joined / returned in the same select statement.
      • hasBatchFetchedAttributes

        public boolean hasBatchFetchedAttributes()
        Return is any mappings are always batch fetched.
      • hasInBatchFetchedAttribute

        public boolean hasInBatchFetchedAttribute()
        Return is any mappings are always batch fetched using IN.
      • setHasInBatchFetchedAttribute

        public void setHasInBatchFetchedAttribute​(boolean hasInBatchFetchedAttribute)
        Set if any mappings are always batch fetched using IN.
      • getMappingForAttributeName

        public DatabaseMapping getMappingForAttributeName​(String name)
        Return the mapping for the specified attribute name.
      • getReadOnlyMappingsForField

        public List<DatabaseMapping> getReadOnlyMappingsForField​(DatabaseField field)
        Return all the read-only mapping for the specified field.
      • getMappingsByAttribute

        protected Map<String,​DatabaseMapping> getMappingsByAttribute()
        Return all the mapping to attribute associations
      • getReadOnlyMappingsByField

        public Map<DatabaseField,​List<DatabaseMapping>> getReadOnlyMappingsByField()
        INTERNAL: Return all the read-only mapping to field associations
      • getNonPrimaryKeyMappings

        protected List<DatabaseMapping> getNonPrimaryKeyMappings()
        Return the non primary key mappings.
      • getParentObjectForField

        public Object getParentObjectForField​(DatabaseField databaseField,
                                              Object domainObject)
        Return the base value that is mapped to for given field.
      • getPrimaryKeyClassifications

        public List<Class> getPrimaryKeyClassifications()
        Return primary key classifications. These are used to ensure a consistent type for the pk values.
      • getPrimaryKeyExpression

        public Expression getPrimaryKeyExpression()
        Return the primary key expression
      • getPrimaryKeyMappings

        public List<DatabaseMapping> getPrimaryKeyMappings()
        Return primary key mappings.
      • getTargetFieldForQueryKeyName

        public DatabaseField getTargetFieldForQueryKeyName​(String queryKeyName)
        INTERNAL: return a database field based on a query key name
      • isPrimaryKeyComponentInvalid

        public boolean isPrimaryKeyComponentInvalid​(Object keyValue,
                                                    int index)
      • recordPrivateOwnedRemovals

        public void recordPrivateOwnedRemovals​(Object object,
                                               UnitOfWorkImpl uow,
                                               boolean initialPass)
      • initializeJoinedAttributes

        public void initializeJoinedAttributes()
        INTERNAL: Iterates through all one to one mappings and checks if any of them use joining.

        By caching the result query execution in the case where there are no joined attributes can be improved.

      • initializeBatchFetchedAttributes

        public void initializeBatchFetchedAttributes()
        INTERNAL: Iterates through all one to one mappings and checks if any of them use batch fetching.

        By caching the result query execution in the case where there are no batch fetched attributes can be improved.

      • instantiateClone

        public Object instantiateClone​(Object domainObject,
                                       AbstractSession session)
        Returns the clone of the specified object. This is called only from unit of work. This only instantiates the clone instance, it does not clone the attributes, this allows the stub of the clone to be registered before cloning its parts.
      • instantiateWorkingCopyClone

        public Object instantiateWorkingCopyClone​(Object domainObject,
                                                  AbstractSession session)
        Returns the clone of the specified object. This is called only from unit of work. The domainObject sent as parameter is always a copy from the parent of unit of work. bug 2612602 make a call to build a working clone. This will in turn call the copy policy to make a working clone. This allows for lighter and heavier clones to be created based on their use. this allows the stub of the clone to be registered before cloning its parts.
      • instantiateWorkingCopyCloneFromRow

        public Object instantiateWorkingCopyCloneFromRow​(AbstractRecord row,
                                                         ObjectBuildingQuery query,
                                                         Object primaryKey,
                                                         UnitOfWorkImpl unitOfWork)
        It is now possible to build working copy clones directly from rows.

        An intermediary original is no longer needed.

        This has ramifications to the copy policy and cmp, for clones are no longer built via cloning.

        Instead the copy policy must in some cases not copy at all. this allows the stub of the clone to be registered before cloning its parts.

      • isPrimaryKeyMapping

        public boolean isPrimaryKeyMapping​(DatabaseMapping mapping)
      • iterate

        public void iterate​(DescriptorIterator iterator)
        INTERNAL: Perform the iteration operation on the objects attributes through the mappings.
      • mergeChangesIntoObject

        public void mergeChangesIntoObject​(Object target,
                                           ObjectChangeSet changeSet,
                                           Object source,
                                           MergeManager mergeManager,
                                           AbstractSession targetSession)
        INTERNAL: Merge changes between the objects, this merge algorithm is dependent on the merge manager.
      • mergeChangesIntoObject

        public void mergeChangesIntoObject​(Object target,
                                           ObjectChangeSet changeSet,
                                           Object source,
                                           MergeManager mergeManager,
                                           AbstractSession targetSession,
                                           boolean isTargetCloneOfOriginal,
                                           boolean shouldMergeFetchGroup)
        INTERNAL: Merge changes between the objects, this merge algorithm is dependent on the merge manager.
      • mergeIntoObject

        public void mergeIntoObject​(Object target,
                                    boolean isUnInitialized,
                                    Object source,
                                    MergeManager mergeManager,
                                    AbstractSession targetSession)
        INTERNAL: Merge the contents of one object into another, this merge algorithm is dependent on the merge manager. This merge also prevents the extra step of calculating the changes when it is not required.
      • mergeIntoObject

        public void mergeIntoObject​(Object target,
                                    ObjectChangeSet changeSet,
                                    boolean isUnInitialized,
                                    Object source,
                                    MergeManager mergeManager,
                                    AbstractSession targetSession,
                                    boolean cascadeOnly,
                                    boolean isTargetCloneOfOriginal,
                                    boolean shouldMergeFetchGroup)
        INTERNAL: Merge the contents of one object into another, this merge algorithm is dependent on the merge manager. This merge also prevents the extra step of calculating the changes when it is not required. If 'cascadeOnly' is true, only foreign reference mappings are merged. If 'isTargetCloneOfOriginal' then the target was create through a shallow clone of the source, so merge basics is not required.
      • populateAttributesForClone

        public void populateAttributesForClone​(Object original,
                                               CacheKey cacheKey,
                                               Object clone,
                                               Integer refreshCascade,
                                               AbstractSession cloningSession)
        Clones the attributes of the specified object. This is called only from unit of work. The domainObject sent as parameter is always a copy from the parent of unit of work.
      • rehashFieldDependancies

        public void rehashFieldDependancies​(AbstractSession session)
        Rehash any maps based on fields. This is used to clone descriptors for aggregates, which hammer field names, it is probably better not to hammer the field name and this should be refactored.
      • setDescriptor

        public void setDescriptor​(ClassDescriptor aDescriptor)
        Set the descriptor.
      • setMappingsByAttribute

        protected void setMappingsByAttribute​(Map<String,​DatabaseMapping> theAttributeMappings)
        All the mappings and their respective attribute associations are cached for performance improvement.
      • setMappingsByField

        public void setMappingsByField​(Map<DatabaseField,​DatabaseMapping> theFieldMappings)
        INTERNAL: All the mappings and their respective field associations are cached for performance improvement.
      • setReadOnlyMappingsByField

        public void setReadOnlyMappingsByField​(Map<DatabaseField,​List<DatabaseMapping>> theReadOnlyFieldMappings)
        INTERNAL: All the read-only mappings and their respective field associations are cached for performance improvement.
      • setNonPrimaryKeyMappings

        protected void setNonPrimaryKeyMappings​(List<DatabaseMapping> theNonPrimaryKeyMappings)
        The non primary key mappings are cached to improve performance.
      • setPrimaryKeyClassifications

        public void setPrimaryKeyClassifications​(List<Class> primaryKeyClassifications)
        INTERNAL: Set primary key classifications. These are used to ensure a consistent type for the pk values.
      • setPrimaryKeyExpression

        public void setPrimaryKeyExpression​(Expression criteria)
        The primary key expression is cached to improve performance.
      • setPrimaryKeyMappings

        protected void setPrimaryKeyMappings​(List<DatabaseMapping> thePrimaryKeyMappings)
        The primary key mappings are cached to improve performance.
      • unwrapObject

        public Object unwrapObject​(Object proxy,
                                   AbstractSession session)
        Unwrap the object if required. This is used for the wrapper policy support and EJB.
      • updateCachedAttributes

        public void updateCachedAttributes​(PersistenceEntity persistenceEntity,
                                           CacheKey cacheKey,
                                           Object primaryKey)
        INTERNAL: Used to updated any attributes that may be cached on a woven entity
      • verifyDelete

        public boolean verifyDelete​(Object object,
                                    AbstractSession session)
        Verify that an object has been deleted from the database. An object can span multiple tables. A query is performed on each of these tables using the primary key values of the object as the selection criteria. If the query returns a result then the object has not been deleted from the database. If no result is returned then each of the mappings is asked to verify that the object has been deleted. If all mappings answer true then the result is true.
      • hasWrapperPolicy

        public boolean hasWrapperPolicy()
        Return if the descriptor has a wrapper policy. Cache for performance.
      • setHasWrapperPolicy

        public void setHasWrapperPolicy​(boolean hasWrapperPolicy)
        Set if the descriptor has a wrapper policy. Cached for performance.
      • wrapObject

        public Object wrapObject​(Object implementation,
                                 AbstractSession session)
        Wrap the object if required. This is used for the wrapper policy support and EJB.
      • isXMLObjectBuilder

        public boolean isXMLObjectBuilder()
      • getLockAttribute

        public String getLockAttribute()
      • shouldKeepRow

        public boolean shouldKeepRow()
      • hasCacheIndexesInSopObject

        public boolean hasCacheIndexesInSopObject()