Class ObjectBuilder
- All Implemented Interfaces:
Serializable
,Cloneable
- Direct Known Subclasses:
XMLObjectBuilder
Purpose: Object builder is one of the behavior class attached to descriptor. It is responsible for building objects, rows, and extracting primary keys from the object and the rows.
- Since:
- TOPLink/Java 1.0
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected List
<DatabaseMapping> PERF: Cache mapping that use batch fetching.protected List
<DatabaseMapping> PERF: Cache mappings that require cloning.protected ClassDescriptor
protected List
<DatabaseMapping> PERF: Cache mappings that are eager loaded.protected Map
<DatabaseField, DatabaseField> Used to maintain identity on the field objects.protected boolean
PERF: is there an cache index field that's would not be selected by SOP query.protected boolean
PERF: Cache mapping that use batch fetching.protected boolean
PERF: Cache if has a wrapper policy.protected boolean
PERF: Cache if is a simple mapping, all direct.protected List
<DatabaseMapping> PERF: Cache mapping that use joining.protected String
attribute name corresponding to optimistic lock field, set only if optimistic locking is usedprotected Map
<String, DatabaseMapping> Mappings keyed by attribute name.protected Map
<DatabaseField, DatabaseMapping> Mappings keyed by database field.protected boolean
indicates whether part of primary key is unmapped - may happen only in case AggregateObject or AggregateCollection descriptor.protected List
<DatabaseMapping> All mapping other than primary key mappings.The types for the primary key fields, in same order as descriptor's primary key fields.protected Expression
Expression for querying an object by primary key.protected List
<DatabaseMapping> Mapping for the primary key fields.protected Map
<DatabaseField, List<DatabaseMapping>> List of read-only mappings using a database field.protected List
<DatabaseMapping> PERF: Cache relationship mappings.protected AbstractDirectMapping
PERF: Cache sequence mappings.protected boolean
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. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addPrimaryKeyForNonDefaultTable
(AbstractRecord databaseRow) Add the primary key and its value to the Record for all the non default tables.void
addPrimaryKeyForNonDefaultTable
(AbstractRecord databaseRow, Object object, AbstractSession session) Add the primary key and its value to the Record for all the non default tables.void
assignReturnRow
(Object object, AbstractSession writeSession, AbstractRecord row, ObjectChangeSet changeSet) Assign the fields in the row back into the object.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).protected void
assignReturnValueToMapping
(Object object, ReadObjectQuery query, AbstractRecord row, DatabaseField field, DatabaseMapping mapping, Collection handledMappings, ObjectChangeSet changeSet) INTERNAL: Assign values from objectRow to the object through the mapping.protected Object
assignSequenceNumber
(Object object, Object sequenceValue, AbstractSession writeSession, WriteObjectQuery writeQuery) INTERNAL: Update the object primary key by fetching a new sequence number from the accessor.assignSequenceNumber
(Object object, AbstractSession writeSession) INTERNAL: Update the object primary key by fetching a new sequence number from the accessor.assignSequenceNumber
(WriteObjectQuery writeQuery) INTERNAL: Update the writeQuery's object primary key by fetching a new sequence number from the accessor.assignSequenceNumber
(WriteObjectQuery writeQuery, Object sequenceValue) INTERNAL: Update the writeQuery's object primary key by fetching a new sequence number from the accessor.void
buildAttributesIntoObject
(Object domainObject, CacheKey cacheKey, AbstractRecord databaseRow, ObjectBuildingQuery query, JoinedAttributeManager joinManager, FetchGroup executionFetchGroup, boolean forRefresh, AbstractSession targetSession) Each mapping is recursed to assign values from the Record to the attributes in the domain object.protected boolean
buildAttributesIntoObjectSOP
(Object domainObject, CacheKey cacheKey, AbstractRecord databaseRow, ObjectBuildingQuery query, JoinedAttributeManager joinManager, FetchGroup executionFetchGroup, boolean forRefresh, AbstractSession targetSession) Each mapping is recursed to assign values from the Record to the attributes in the domain object.void
buildAttributesIntoShallowObject
(Object original, AbstractRecord databaseRow, ObjectBuildingQuery query) 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.void
buildAttributesIntoWorkingCopyClone
(Object clone, CacheKey sharedCacheKey, ObjectBuildingQuery query, JoinedAttributeManager joinManager, AbstractRecord databaseRow, UnitOfWorkImpl unitOfWork, boolean forRefresh) INTERNAL: For reading through the write connection when in transaction, populate the clone directly from the database row.protected boolean
buildAttributesIntoWorkingCopyCloneSOP
(Object clone, CacheKey sharedCacheKey, ObjectBuildingQuery query, JoinedAttributeManager joinManager, AbstractRecord databaseRow, UnitOfWorkImpl unitOfWork, boolean forRefresh) For reading through the write connection when in transaction, populate the clone directly from the database row.buildBackupClone
(Object clone, UnitOfWorkImpl unitOfWork) Returns the backup clone of the specified object.buildDeleteExpression
(DatabaseTable table, AbstractRecord row, boolean usesOptimisticLocking) Build and return the expression to use as the where clause to delete an object.buildExpressionFromExample
(Object queryObject, QueryByExamplePolicy policy, Expression expressionBuilder, Map processedObjects, AbstractSession session) INTERNAL: This method is used when Query By Example is used.Return a new instance of the receiver's javaClass.protected Object
buildObject
(boolean returnCacheKey, ObjectBuildingQuery query, AbstractRecord databaseRow, AbstractSession session, Object primaryKey, CacheKey preFetchedCacheKey, ClassDescriptor concreteDescriptor, JoinedAttributeManager joinManager) Return an instance of the receivers javaClass.buildObject
(ObjectBuildingQuery query, AbstractRecord databaseRow, JoinedAttributeManager joinManager) Return an instance of the receivers javaClass.buildObject
(ObjectBuildingQuery query, AbstractRecord databaseRow, JoinedAttributeManager joinManager, AbstractSession session, ClassDescriptor concreteDescriptor, InheritancePolicy inheritancePolicy, boolean isUnitOfWork, boolean shouldCacheQueryResults, boolean shouldUseWrapperPolicy) Return an instance of the receivers javaClass.buildObject
(ObjectLevelReadQuery query, AbstractRecord databaseRow) Return an instance of the receivers javaClass.buildObjectFromResultSet
(ObjectBuildingQuery query, JoinedAttributeManager joinManager, ResultSet resultSet, AbstractSession executionSession, DatabaseAccessor accessor, ResultSetMetaData metaData, DatabasePlatform platform, Vector fieldsList, DatabaseField[] fieldsArray) INTERNAL: Builds a working copy clone directly from a result set.protected Object
buildObjectInUnitOfWork
(ObjectBuildingQuery query, JoinedAttributeManager joinManager, AbstractRecord databaseRow, UnitOfWorkImpl unitOfWork, Object primaryKey, CacheKey preFetchedCacheKey, ClassDescriptor concreteDescriptor) For executing all reads on the UnitOfWork, the session when building objects from rows will now be the UnitOfWork.buildObjectsFromCursorInto
(ReadAllQuery query, List databaseRows, Object domainObjects) Return a container which contains the instances of the receivers javaClass.buildObjectsFromResultSetInto
(ReadAllQuery query, ResultSet resultSet, Vector fields, DatabaseField[] fieldsArray, Object domainObjects) Version of buildObjectsInto method that takes call instead of rows.buildObjectsInto
(ReadAllQuery query, List databaseRows, Object domainObjects) Return a container which contains the instances of the receivers javaClass.void
buildPrimaryKeyAttributesIntoObject
(Object original, AbstractRecord databaseRow, ObjectBuildingQuery query, AbstractSession session) INTERNAL: Build just the primary key mappings into the object.Build the primary key expression for the secondary table.buildPrimaryKeyExpressionFromKeys
(Object primaryKey, AbstractSession session) Build the primary key expression from the specified primary key values.buildPrimaryKeyExpressionFromObject
(Object domainObject, AbstractSession session) Build the primary key expression from the specified domain object.protected Object
buildProtectedObject
(boolean returnCacheKey, ObjectBuildingQuery query, AbstractRecord databaseRow, AbstractSession session, Object primaryKey, CacheKey preFetchedCacheKey, ClassDescriptor concreteDescriptor, JoinedAttributeManager joinManager) Return an instance of the receivers javaClass.buildRow
(Object object, AbstractSession session, DatabaseMapping.WriteType writeType) Build the row representation of an object.buildRow
(AbstractRecord databaseRow, Object object, AbstractSession session, DatabaseMapping.WriteType writeType) Build the row representation of an object.buildRowForShallowInsert
(Object object, AbstractSession session) Build the row representation of the object for update.buildRowForShallowInsert
(AbstractRecord databaseRow, Object object, AbstractSession session) Build the row representation of the object for update.buildRowForTranslation
(Object object, AbstractSession session) Build the row representation of an object.buildRowForUpdate
(AbstractRecord databaseRow, WriteObjectQuery query) Build into the row representation of the object for update.Build the row representation of the object for update.buildRowForUpdateAfterShallowInsert
(Object object, AbstractSession session, DatabaseTable table) Build the row representation of the object that contains only the fields nullified by shallow insert.buildRowForUpdateAfterShallowInsert
(AbstractRecord databaseRow, Object object, AbstractSession session, DatabaseTable table) Build the row representation of the object that contains only the fields nullified by shallow insert.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
(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.Build the row representation of the object for update.Build the row representation of an object.buildRowFromPrimaryKeyValues
(Object key, AbstractSession session) Build the row from the primary key values.buildRowWithChangeSet
(AbstractRecord databaseRow, ObjectChangeSet objectChangeSet, AbstractSession session, DatabaseMapping.WriteType writeType) Build the row representation of an object.buildTemplateInsertRow
(AbstractSession session) Build the row of all of the fields used for insertion.void
buildTemplateInsertRow
(AbstractSession session, AbstractRecord databaseRow) buildTemplateUpdateRow
(AbstractSession session) Build the row representation of the object for update.buildUpdateExpression
(DatabaseTable table, AbstractRecord transactionRow, AbstractRecord modifyRow) Build and return the expression to use as the where clause to an update object.protected Object
buildWorkingCopyCloneFromRow
(ObjectBuildingQuery query, JoinedAttributeManager joinManager, AbstractRecord databaseRow, UnitOfWorkImpl unitOfWork, Object primaryKey, CacheKey preFetchedCacheKey) INTERNAL: Builds a working copy clone directly from the database row.protected Object
buildWorkingCopyCloneNormally
(ObjectBuildingQuery query, AbstractRecord databaseRow, UnitOfWorkImpl unitOfWork, Object primaryKey, CacheKey preFetchedCacheKey, ClassDescriptor concreteDescriptor, JoinedAttributeManager joinManager) buildWorkingCopyCloneFromRow is an alternative to this which is the normal behavior.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.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.void
cascadeDiscoverAndPersistUnregisteredNewObjects
(Object object, Map newObjects, Map unregisteredExistingObjects, Map visitedObjects, UnitOfWorkImpl uow, Set cascadeErrors) INTERNAL: Cascade discover and persist new objects during commit.void
cascadePerformRemove
(Object object, UnitOfWorkImpl uow, Map visitedObjects) INTERNAL: This method is used by the UnitOfWork to cascade registration of new objects.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.void
cascadeRegisterNewForCreate
(Object object, UnitOfWorkImpl uow, Map visitedObjects) INTERNAL: This method is used by the UnitOfWork to cascade registration of new objects.void
clearPrimaryKey
(Object object) Clear any primary key cache data in the object.clone()
Returns a clone of itself.compareForChange
(Object clone, Object backUp, UnitOfWorkChangeSet changeSet, AbstractSession session) INTERNAL: This method creates a records change set for a particular object.boolean
compareObjects
(Object firstObject, Object secondObject, AbstractSession session) Compares the two specified objectsvoid
Copy each attribute from one object into the other.void
Copy each attribute from one object into the other.copyObject
(Object original, CopyGroup copyGroup) Return a copy of the object.protected void
copyQueryInfoToCacheKey
(CacheKey cacheKey, ObjectBuildingQuery query, AbstractRecord databaseRow, AbstractSession session, ClassDescriptor concreteDescriptor) Initialize a cache key.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.createObjectChangeSet
(Object clone, UnitOfWorkChangeSet uowChangeSet, boolean isNew, AbstractSession session) INTERNAL: Used by the ObjectBuilder to create an ObjectChangeSet for the specified clone object.createObjectChangeSet
(Object clone, UnitOfWorkChangeSet uowChangeSet, AbstractSession session) INTERNAL: Used by the ObjectBuilder to create an ObjectChangeSet for the specified clone object.void
Creates and stores primary key expression.createRecord
(int size, AbstractSession session) Create a new row/record for the object builder.createRecord
(AbstractSession session) Create a new row/record for the object builder.protected AbstractRecord
createRecordForPKExtraction
(int size, AbstractSession session) Create a new row/record for the object builder.createRecordFromXMLContext
(XMLContext context) Create a new row/record from XMLContext.extractPrimaryKeyFromExpression
(boolean requiresExactMatch, Expression expression, AbstractRecord translationRow, AbstractSession session) Return the row with primary keys and their values from the given expression.extractPrimaryKeyFromObject
(Object domainObject, AbstractSession session) Extract primary key attribute values from the domainObject.extractPrimaryKeyFromObject
(Object domainObject, AbstractSession session, boolean shouldReturnNullIfNull) Extract primary key attribute values from the domainObject.extractPrimaryKeyFromRow
(AbstractRecord databaseRow, AbstractSession session) Extract primary key values from the specified row.extractPrimaryKeyRowFromExpression
(Expression expression, AbstractRecord translationRow, AbstractSession session) Return the row with primary keys and their values from the given expression.extractPrimaryKeyRowFromObject
(Object domainObject, AbstractSession session) Extract primary key attribute values from the domainObject.extractRowFromExpression
(Expression expression, AbstractRecord translationRow, AbstractSession session) Return the row from the given expression.extractValueFromObjectForField
(Object domainObject, DatabaseField field, AbstractSession session) Extract the value of the primary key attribute from the specified object.void
fixObjectReferences
(Object object, Map<Object, ObjectDescriptor> objectDescriptors, Map<Object, Object> processedObjects, ObjectLevelReadQuery query, DistributedSession session) INTERNAL: An object has been serialized from the server to the client.getBaseChangeRecordForField
(ObjectChangeSet objectChangeSet, Object object, DatabaseField databaseField, AbstractSession session) Return the base ChangeRecord for the given DatabaseField.getBaseMappingForField
(DatabaseField databaseField) Return the base mapping for the given DatabaseField.getBaseValueForField
(DatabaseField databaseField, Object domainObject) Return the base value that is mapped to for given field.Return the mappings that are always batch fetched.PERF: Return all mappings that require cloning.Return the descriptorPERF: Return all mappings that are eager loaded (but use indirection).Class
<?> getFieldClassification
(DatabaseField fieldToClassify) INTERNAL: Return the classification for the field contained in the mapping.Return the field used for the query key name.Return the fields map.Answers the attributes which are always joined to the original query on reads.Return the mapping for the specified attribute name.getMappingForField
(DatabaseField field) Return al the mapping for the specified field.protected Map
<String, DatabaseMapping> Return all the mapping to attribute associationsINTERNAL: Return all the mapping to field associationsprotected List
<DatabaseMapping> Return the non primary key mappings.getParentObjectForField
(DatabaseField databaseField, Object domainObject) Return the base value that is mapped to for given field.Return primary key classifications.Return the primary key expressionReturn primary key mappings.INTERNAL: Return all the read-only mapping to field associationsReturn all the read-only mapping for the specified field.PERF: Return all relationship mappings.PERF: Return the sequence mapping.getTargetFieldForQueryKeyName
(String queryKeyName) INTERNAL: return a database field based on a query key nameboolean
Return is any mappings are always batch fetched.boolean
boolean
Return is any mappings are always batch fetched using IN.boolean
Answers if any attributes are to be joined / returned in the same select statement.boolean
Return if the descriptor has a wrapper policy.protected void
initialize
(ClassDescriptor descriptor) void
initialize
(AbstractSession session) Cache all the mappings by their attribute and fields.void
INTERNAL: Iterates through all one to one mappings and checks if any of them use batch fetching.void
INTERNAL: Iterates through all one to one mappings and checks if any of them use joining.void
initializePrimaryKey
(AbstractSession session) Cache primary key and non primary key mappings.instantiateClone
(Object domainObject, AbstractSession session) Returns the clone of the specified object.void
instantiateEagerMappings
(Object object, AbstractSession session) Force instantiation to any eager mappings.instantiateWorkingCopyClone
(Object domainObject, AbstractSession session) Returns the clone of the specified object.instantiateWorkingCopyCloneFromRow
(AbstractRecord row, ObjectBuildingQuery query, Object primaryKey, UnitOfWorkImpl unitOfWork) It is now possible to build working copy clones directly from rows.boolean
isPrimaryKeyComponentInvalid
(Object keyValue, int index) boolean
isPrimaryKeyExpression
(boolean requiresExactMatch, Expression expression, AbstractSession session) Return if the expression is by primary key.boolean
isPrimaryKeyMapping
(DatabaseMapping mapping) boolean
isSimple()
PERF: Return if the descriptor has no complex mappings, all direct.boolean
void
iterate
(DescriptorIterator iterator) INTERNAL: Perform the iteration operation on the objects attributes through the mappings.void
load
(Object object, AttributeGroup group, AbstractSession session, boolean fromFetchGroup) Force instantiation to any mappings in the load group.void
loadAll
(Object object, AbstractSession session) Force instantiation of all indirections.void
loadAll
(Object object, AbstractSession session, IdentityHashSet loaded) protected void
loadBatchReadAttributes
(ClassDescriptor concreteDescriptor, Object sourceObject, CacheKey cacheKey, AbstractRecord databaseRow, ObjectBuildingQuery query, JoinedAttributeManager joinManager, boolean isTargetProtected) protected void
loadJoinedAttributes
(ClassDescriptor concreteDescriptor, Object sourceObject, CacheKey cacheKey, AbstractRecord databaseRow, JoinedAttributeManager joinManager, ObjectBuildingQuery query, boolean isTargetProtected) 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.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.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.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.void
populateAttributesForClone
(Object original, CacheKey cacheKey, Object clone, Integer refreshCascade, AbstractSession cloningSession) Clones the attributes of the specified object.protected void
postBuildAttributesIntoObjectEvent
(Object domainObject, AbstractRecord databaseRow, ObjectBuildingQuery query, boolean forRefresh) protected void
postBuildAttributesIntoWorkingCopyCloneEvent
(Object clone, AbstractRecord databaseRow, ObjectBuildingQuery query, UnitOfWorkImpl unitOfWork, boolean forRefresh) void
postInitialize
(AbstractSession session) INTERNAL: Post initializations after mappings are initialized.void
recordPrivateOwnedRemovals
(Object object, UnitOfWorkImpl uow, boolean initialPass) protected boolean
refreshObjectIfRequired
(ClassDescriptor concreteDescriptor, CacheKey cacheKey, Object domainObject, ObjectBuildingQuery query, JoinedAttributeManager joinManager, AbstractRecord databaseRow, AbstractSession session, boolean targetIsProtected) This method is called when a cached Entity needs to be refreshedvoid
rehashFieldDependancies
(AbstractSession session) Rehash any maps based on fields.void
setDescriptor
(ClassDescriptor aDescriptor) Set the descriptor.protected void
setFieldsMap
(Map fieldsMap) Return the fields map.void
setHasInBatchFetchedAttribute
(boolean hasInBatchFetchedAttribute) Set if any mappings are always batch fetched using IN.void
setHasWrapperPolicy
(boolean hasWrapperPolicy) Set if the descriptor has a wrapper policy.protected void
setMappingsByAttribute
(Map<String, DatabaseMapping> theAttributeMappings) All the mappings and their respective attribute associations are cached for performance improvement.void
setMappingsByField
(Map<DatabaseField, DatabaseMapping> theFieldMappings) INTERNAL: All the mappings and their respective field associations are cached for performance improvement.protected void
setNonPrimaryKeyMappings
(List<DatabaseMapping> theNonPrimaryKeyMappings) The non primary key mappings are cached to improve performance.void
setPrimaryKeyClassifications
(List<Class<?>> primaryKeyClassifications) INTERNAL: Set primary key classifications.void
setPrimaryKeyExpression
(Expression criteria) The primary key expression is cached to improve performance.protected void
setPrimaryKeyMappings
(List<DatabaseMapping> thePrimaryKeyMappings) The primary key mappings are cached to improve performance.void
setReadOnlyMappingsByField
(Map<DatabaseField, List<DatabaseMapping>> theReadOnlyFieldMappings) INTERNAL: All the read-only mappings and their respective field associations are cached for performance improvement.void
setSequenceMapping
(AbstractDirectMapping sequenceMapping) PERF: Set the sequence mapping.boolean
toString()
void
trimFieldsForInsert
(AbstractSession session, AbstractRecord databaseRow) INTERNAL Remove a potential sequence number field and invoke the ReturningPolicy trimModifyRowsForInsert methodunwrapObject
(Object proxy, AbstractSession session) Unwrap the object if required.void
updateCachedAttributes
(PersistenceEntity persistenceEntity, CacheKey cacheKey, Object primaryKey) INTERNAL: Used to updated any attributes that may be cached on a woven entityvoid
validate
(AbstractSession session) Validates the object builder.boolean
verifyDelete
(Object object, AbstractSession session) Verify that an object has been deleted from the database.wrapObject
(Object implementation, AbstractSession session) Wrap the object if required.writeIntoRowFromPrimaryKeyValues
(AbstractRecord row, Object primaryKey, AbstractSession session, boolean convert) Build the row from the primary key values.
-
Field Details
-
descriptor
-
mappingsByAttribute
Mappings keyed by attribute name. -
mappingsByField
Mappings keyed by database field. -
readOnlyMappingsByField
List of read-only mappings using a database field. -
fieldsMap
Used to maintain identity on the field objects. Ensure they get the correct index/type. -
Mapping for the primary key fields.
-
primaryKeyClassifications
The types for the primary key fields, in same order as descriptor's primary key fields. -
nonPrimaryKeyMappings
All mapping other than primary key mappings. -
primaryKeyExpression
Expression for querying an object by primary key. -
joinedAttributes
PERF: Cache mapping that use joining. -
batchFetchedAttributes
PERF: Cache mapping that use batch fetching. -
hasInBatchFetchedAttribute
protected boolean hasInBatchFetchedAttributePERF: Cache mapping that use batch fetching. -
cloningMappings
PERF: Cache mappings that require cloning. -
eagerMappings
PERF: Cache mappings that are eager loaded. -
relationshipMappings
PERF: Cache relationship mappings. -
isSimple
protected boolean isSimplePERF: Cache if is a simple mapping, all direct. -
hasWrapperPolicy
protected boolean hasWrapperPolicyPERF: Cache if has a wrapper policy. -
sequenceMapping
PERF: Cache sequence mappings. -
mayHaveNullInPrimaryKey
protected boolean mayHaveNullInPrimaryKeyindicates whether part of primary key is unmapped - may happen only in case AggregateObject or AggregateCollection descriptor. -
lockAttribute
attribute name corresponding to optimistic lock field, set only if optimistic locking is used -
shouldKeepRow
protected boolean shouldKeepRowPERF: 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 hasCacheIndexesInSopObjectPERF: 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 Details
-
ObjectBuilder
-
-
Method Details
-
initialize
-
createRecord
Create a new row/record for the object builder. This allows subclasses to define different record types.- Specified by:
createRecord
in classCoreObjectBuilder<AbstractRecord,
AbstractSession, DatabaseField, DatabaseMapping>
-
createRecord
Create a new row/record for the object builder. This allows subclasses to define different record types. -
createRecordForPKExtraction
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
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
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. -
assignReturnValueToMapping
protected void assignReturnValueToMapping(Object object, ReadObjectQuery query, AbstractRecord row, DatabaseField field, DatabaseMapping mapping, Collection handledMappings, ObjectChangeSet changeSet) INTERNAL: Assign values from objectRow to the object through the mapping. 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
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.
-
buildAttributesIntoObject
public void buildAttributesIntoObject(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.- Throws:
DatabaseException
-
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
-
postBuildAttributesIntoObjectEvent
protected void postBuildAttributesIntoObjectEvent(Object domainObject, AbstractRecord databaseRow, ObjectBuildingQuery query, boolean forRefresh) -
buildBackupClone
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. -
buildNewInstance
Return a new instance of the receiver's javaClass.- Specified by:
buildNewInstance
in classCoreObjectBuilder<AbstractRecord,
AbstractSession, DatabaseField, DatabaseMapping>
-
buildObject
Return an instance of the receivers javaClass. Set the attributes of an instance from the values stored in the database row. -
buildObject
public Object buildObject(ObjectBuildingQuery query, AbstractRecord databaseRow, JoinedAttributeManager joinManager) Return an instance of the receivers javaClass. Set the attributes of an instance from the values stored in the database row. -
buildObject
public Object buildObject(ObjectBuildingQuery query, AbstractRecord databaseRow, JoinedAttributeManager joinManager, AbstractSession session, ClassDescriptor concreteDescriptor, InheritancePolicy inheritancePolicy, boolean isUnitOfWork, boolean shouldCacheQueryResults, boolean shouldUseWrapperPolicy) Return an instance of the receivers javaClass. Set the attributes of an instance from the values stored in the database row. This is wrapper method with semaphore logic. -
instantiateEagerMappings
Force instantiation to any eager mappings. -
load
public void load(Object object, AttributeGroup group, AbstractSession session, boolean fromFetchGroup) Force instantiation to any mappings in the load group. -
loadAll
Force instantiation of all indirections. -
loadAll
-
buildObjectInUnitOfWork
protected Object buildObjectInUnitOfWork(ObjectBuildingQuery query, JoinedAttributeManager joinManager, AbstractRecord databaseRow, UnitOfWorkImpl unitOfWork, Object primaryKey, CacheKey preFetchedCacheKey, ClassDescriptor concreteDescriptor) throws DatabaseException, QueryException For executing all reads on the UnitOfWork, the session when building objects from rows will now be the UnitOfWork. Useful if the rows were read via a dirty write connection and we want to avoid putting uncommitted data in the global cache.Decides whether to call either buildWorkingCopyCloneFromRow (bypassing shared cache) or buildWorkingCopyCloneNormally (placing the result in the shared cache).
- Throws:
DatabaseException
QueryException
-
buildWorkingCopyCloneNormally
protected Object buildWorkingCopyCloneNormally(ObjectBuildingQuery query, AbstractRecord databaseRow, UnitOfWorkImpl unitOfWork, Object primaryKey, CacheKey preFetchedCacheKey, ClassDescriptor concreteDescriptor, JoinedAttributeManager joinManager) throws DatabaseException, QueryException buildWorkingCopyCloneFromRow is an alternative to this which is the normal behavior. A row is read from the database, an original is built/refreshed/returned from the shared cache, and the original is registered/conformed/reverted in the UnitOfWork.This default behavior is only safe when the query is executed on a read connection, otherwise uncommitted data might get loaded into the shared cache.
Represents the way TopLink has always worked.
- Throws:
DatabaseException
QueryException
-
buildObject
protected Object buildObject(boolean returnCacheKey, ObjectBuildingQuery query, AbstractRecord databaseRow, AbstractSession session, Object primaryKey, CacheKey preFetchedCacheKey, ClassDescriptor concreteDescriptor, JoinedAttributeManager joinManager) throws DatabaseException, QueryException Return an instance of the receivers javaClass. Set the attributes of an instance from the values stored in the database row.- Throws:
DatabaseException
QueryException
-
buildProtectedObject
protected Object buildProtectedObject(boolean returnCacheKey, ObjectBuildingQuery query, AbstractRecord databaseRow, AbstractSession session, Object primaryKey, CacheKey preFetchedCacheKey, ClassDescriptor concreteDescriptor, JoinedAttributeManager joinManager) throws DatabaseException, QueryException Return an instance of the receivers javaClass. Set the attributes of an instance from the values stored in the database row.- Throws:
DatabaseException
QueryException
-
buildObjectsInto
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. -
buildPrimaryKeyExpression
Build the primary key expression for the secondary table.- Throws:
DescriptorException
-
buildPrimaryKeyExpressionFromKeys
Build the primary key expression from the specified primary key values. -
buildPrimaryKeyExpressionFromObject
Build the primary key expression from the specified domain object. -
buildRow
public AbstractRecord buildRow(Object object, AbstractSession session, DatabaseMapping.WriteType writeType) Build the row representation of an object. -
buildRow
public AbstractRecord buildRow(AbstractRecord databaseRow, Object object, AbstractSession session, DatabaseMapping.WriteType writeType) Build the row representation of an object. -
buildRowForShallowInsert
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. -
buildRowForUpdateAfterShallowInsert
public AbstractRecord buildRowForUpdateAfterShallowInsert(AbstractRecord databaseRow, 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. -
buildRowWithChangeSet
public AbstractRecord buildRowWithChangeSet(AbstractRecord databaseRow, ObjectChangeSet objectChangeSet, AbstractSession session, DatabaseMapping.WriteType writeType) Build the row representation of an object. This is only used for aggregates. -
buildRowForTranslation
Build the row representation of an object. The row built is used only for translations for the expressions in the expression framework. -
buildRowForUpdate
Build the row representation of the object for update. The row built does not contain entries for unchanged attributes. -
buildRowForUpdate
Build into the row representation of the object for update. The row does not contain entries for unchanged attributes. -
buildRowForUpdateWithChangeSet
Build the row representation of the object for update. The row built does not contain entries for uninstantiated attributes. -
buildRowForWhereClause
Build the row representation of an object. -
writeIntoRowFromPrimaryKeyValues
public AbstractRecord writeIntoRowFromPrimaryKeyValues(AbstractRecord row, Object primaryKey, AbstractSession session, boolean convert) Build the row from the primary key values. -
buildRowFromPrimaryKeyValues
Build the row from the primary key values. -
buildTemplateInsertRow
Build the row of all of the fields used for insertion. -
buildTemplateInsertRow
-
trimFieldsForInsert
INTERNAL Remove a potential sequence number field and invoke the ReturningPolicy trimModifyRowsForInsert method -
buildTemplateUpdateRow
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. -
buildPrimaryKeyAttributesIntoObject
public void buildPrimaryKeyAttributesIntoObject(Object original, AbstractRecord databaseRow, ObjectBuildingQuery query, AbstractSession session) throws DatabaseException, QueryException INTERNAL: Build just the primary key mappings into the object.- Throws:
DatabaseException
QueryException
-
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
-
buildAttributesIntoWorkingCopyClone
public void buildAttributesIntoWorkingCopyClone(Object clone, CacheKey sharedCacheKey, ObjectBuildingQuery query, JoinedAttributeManager joinManager, AbstractRecord databaseRow, UnitOfWorkImpl unitOfWork, boolean forRefresh) throws DatabaseException, QueryException INTERNAL: For reading through the write connection when in transaction, populate the clone directly from the database row.- 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
-
postBuildAttributesIntoWorkingCopyCloneEvent
protected void postBuildAttributesIntoWorkingCopyCloneEvent(Object clone, AbstractRecord databaseRow, ObjectBuildingQuery query, UnitOfWorkImpl unitOfWork, boolean forRefresh) -
buildWorkingCopyCloneFromRow
protected Object buildWorkingCopyCloneFromRow(ObjectBuildingQuery query, JoinedAttributeManager joinManager, AbstractRecord databaseRow, UnitOfWorkImpl unitOfWork, Object primaryKey, CacheKey preFetchedCacheKey) throws DatabaseException, QueryException INTERNAL: Builds a working copy clone directly from the database row. This is the key method that allows us to execute queries against a UnitOfWork while in transaction and not cache the results in the shared cache. This is because we might violate transaction isolation by putting uncommitted versions of objects in the shared cache.- Throws:
DatabaseException
QueryException
-
buildObjectFromResultSet
public Object buildObjectFromResultSet(ObjectBuildingQuery query, JoinedAttributeManager joinManager, ResultSet resultSet, AbstractSession executionSession, DatabaseAccessor accessor, ResultSetMetaData metaData, DatabasePlatform platform, Vector fieldsList, DatabaseField[] fieldsArray) throws SQLException INTERNAL: Builds a working copy clone directly from a result set. PERF: This method is optimized for a specific case of building objects so can avoid many of the normal checks, only queries that have this criteria can use this method of building objects. This is wrapper method with semaphore logic.- Throws:
SQLException
-
clone
Returns a clone of itself. -
cascadePerformRemove
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
INTERNAL: This method is used by the UnitOfWork to cascade registration of new objects. It may raise exceptions as described in the EJB3 specification -
compareForChange
public ObjectChangeSet compareForChange(Object clone, Object backUp, UnitOfWorkChangeSet changeSet, AbstractSession session) INTERNAL: This method creates a records change set for a particular object. It should only be used by aggregates.- Returns:
- ObjectChangeSet
-
compareObjects
Compares the two specified objects -
copyInto
Copy each attribute from one object into the other. -
copyInto
Copy each attribute from one object into the other. -
copyObject
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
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
Extract primary key attribute values from the domainObject.- Specified by:
extractPrimaryKeyFromObject
in classCoreObjectBuilder<AbstractRecord,
AbstractSession, DatabaseField, DatabaseMapping>
-
extractPrimaryKeyFromObject
public Object extractPrimaryKeyFromObject(Object domainObject, AbstractSession session, boolean shouldReturnNullIfNull) Extract primary key attribute values from the domainObject. -
extractPrimaryKeyFromRow
Extract primary key values from the specified row. null is returned if the row does not contain the key. -
extractPrimaryKeyRowFromExpression
public AbstractRecord extractPrimaryKeyRowFromExpression(Expression expression, AbstractRecord translationRow, AbstractSession session) Return the row with primary keys and their values from the given expression. -
extractRowFromExpression
public AbstractRecord extractRowFromExpression(Expression expression, AbstractRecord translationRow, AbstractSession session) Return the row from the given expression. -
extractPrimaryKeyRowFromObject
Extract primary key attribute values from the domainObject. -
extractValueFromObjectForField
public Object extractValueFromObjectForField(Object domainObject, DatabaseField field, AbstractSession session) throws DescriptorException Extract the value of the primary key attribute from the specified object.- Throws:
DescriptorException
-
fixObjectReferences
public void fixObjectReferences(Object object, Map<Object, ObjectDescriptor> objectDescriptors, Map<Object, Object> 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
Return the base mapping for the given DatabaseField. -
getBaseValueForField
Return the base value that is mapped to for given field. -
getDescriptor
Return the descriptor -
getFieldClassification
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
Return the field used for the query key name. -
getFieldsMap
Return the fields map. Used to maintain identity on the field objects. Ensure they get the correct index/type. -
setFieldsMap
Return the fields map. Used to maintain identity on the field objects. Ensure they get the correct index/type. -
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
PERF: Return all relationship mappings. -
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
Answers the attributes which are always joined to the original query on reads. -
getBatchFetchedAttributes
Return the mappings that are always batch fetched. -
getSequenceMapping
PERF: Return the sequence mapping. -
setSequenceMapping
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
Return the mapping for the specified attribute name. -
getMappingForField
Return al the mapping for the specified field.- Specified by:
getMappingForField
in classCoreObjectBuilder<AbstractRecord,
AbstractSession, DatabaseField, DatabaseMapping>
-
getReadOnlyMappingsForField
Return all the read-only mapping for the specified field. -
getMappingsByAttribute
Return all the mapping to attribute associations -
getMappingsByField
INTERNAL: Return all the mapping to field associations -
getReadOnlyMappingsByField
INTERNAL: Return all the read-only mapping to field associations -
getNonPrimaryKeyMappings
Return the non primary key mappings. -
getParentObjectForField
Return the base value that is mapped to for given field. -
getPrimaryKeyClassifications
Return primary key classifications. These are used to ensure a consistent type for the pk values. -
getPrimaryKeyExpression
Return the primary key expression -
getPrimaryKeyMappings
Return primary key mappings. -
getTargetFieldForQueryKeyName
INTERNAL: return a database field based on a query key name -
initialize
Cache all the mappings by their attribute and fields.- Throws:
DescriptorException
-
isPrimaryKeyComponentInvalid
-
recordPrivateOwnedRemovals
-
postInitialize
INTERNAL: Post initializations after mappings are initialized.- Throws:
DescriptorException
-
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.
-
copyQueryInfoToCacheKey
protected void copyQueryInfoToCacheKey(CacheKey cacheKey, ObjectBuildingQuery query, AbstractRecord databaseRow, AbstractSession session, ClassDescriptor concreteDescriptor) Initialize a cache key. Called by buildObject and now also by buildWorkingCopyCloneFromRow. -
initializePrimaryKey
Cache primary key and non primary key mappings.- Throws:
DescriptorException
-
instantiateClone
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
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
-
iterate
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. -
loadBatchReadAttributes
protected void loadBatchReadAttributes(ClassDescriptor concreteDescriptor, Object sourceObject, CacheKey cacheKey, AbstractRecord databaseRow, ObjectBuildingQuery query, JoinedAttributeManager joinManager, boolean isTargetProtected) -
loadJoinedAttributes
protected void loadJoinedAttributes(ClassDescriptor concreteDescriptor, Object sourceObject, CacheKey cacheKey, AbstractRecord databaseRow, JoinedAttributeManager joinManager, ObjectBuildingQuery query, boolean isTargetProtected) -
refreshObjectIfRequired
protected boolean refreshObjectIfRequired(ClassDescriptor concreteDescriptor, CacheKey cacheKey, Object domainObject, ObjectBuildingQuery query, JoinedAttributeManager joinManager, AbstractRecord databaseRow, AbstractSession session, boolean targetIsProtected) This method is called when a cached Entity needs to be refreshed -
rehashFieldDependancies
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
Set the descriptor. -
setMappingsByAttribute
All the mappings and their respective attribute associations are cached for performance improvement. -
setMappingsByField
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
The non primary key mappings are cached to improve performance. -
setPrimaryKeyClassifications
INTERNAL: Set primary key classifications. These are used to ensure a consistent type for the pk values. -
setPrimaryKeyExpression
The primary key expression is cached to improve performance. -
setPrimaryKeyMappings
The primary key mappings are cached to improve performance. -
toString
-
unwrapObject
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 -
validate
Validates the object builder. This is done once the object builder initialized and descriptor fires this validation.- Throws:
DescriptorException
-
verifyDelete
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
Wrap the object if required. This is used for the wrapper policy support and EJB. -
isXMLObjectBuilder
public boolean isXMLObjectBuilder() -
getLockAttribute
-
shouldKeepRow
public boolean shouldKeepRow() -
hasCacheIndexesInSopObject
public boolean hasCacheIndexesInSopObject() -
createRecordFromXMLContext
Description copied from class:CoreObjectBuilder
Create a new row/record from XMLContext.- Specified by:
createRecordFromXMLContext
in classCoreObjectBuilder<AbstractRecord,
AbstractSession, DatabaseField, DatabaseMapping>
-