/** * INTERNAL: This method can be used when an Indirection Object is required * to be built from a provided ValueHolderInterface object. This may be used * for custom value holder types. Certain policies like the * TransparentIndirectionPolicy may wrap the valueholder in another object. */ public Object buildIndirectObject(ValueHolderInterface valueHolder){ return buildIndirectContainer(valueHolder); } /**
/** * INTERNAL: This method can be used when an Indirection Object is required * to be built from a provided ValueHolderInterface object. This may be used * for custom value holder types. Certain policies like the * TransparentIndirectionPolicy may wrap the valueholder in another object. */ public Object buildIndirectObject(ValueHolderInterface valueHolder){ return buildIndirectContainer(valueHolder); } /**
/** * INTERNAL: This method can be used when an Indirection Object is required * to be built from a provided ValueHolderInterface object. This may be used * for custom value holder types. Certain policies like the * TransparentIndirectionPolicy may wrap the valueholder in another object. */ public Object buildIndirectObject(ValueHolderInterface valueHolder){ return buildIndirectContainer(valueHolder); } /**
/** * INTERNAL: * Verify that the value of the attribute within an instantiated object * is of the appropriate type for the indirection policy. * In this case, the attribute must be non-null and it must be at least a * subclass or implementor of the container type. * If the value is null return a new indirection object to be used for the attribute. */ public Object validateAttributeOfInstantiatedObject(Object attributeValue) { // PERF: If the value is null, create a new value holder instance for the attribute value, // this allows for indirection attributes to not be instantiated in the constructor as they // are typically replaced when reading or cloning so is very inefficient to initialize. if (attributeValue == null) { return buildIndirectContainer(); } return attributeValue; }
/** * INTERNAL: * Verify that the value of the attribute within an instantiated object * is of the appropriate type for the indirection policy. * In this case, the attribute must be non-null and it must be at least a * subclass or implementor of the container type. * If the value is null return a new indirection object to be used for the attribute. */ public Object validateAttributeOfInstantiatedObject(Object attributeValue) { // PERF: If the value is null, create a new value holder instance for the attribute value, // this allows for indirection attributes to not be instantiated in the constructor as they // are typically replaced when reading or cloning so is very inefficient to initialize. if (attributeValue == null) { return buildIndirectContainer(); } return attributeValue; }
/** * INTERNAL: * Verify that the value of the attribute within an instantiated object * is of the appropriate type for the indirection policy. * In this case, the attribute must be non-null and it must be at least a * subclass or implementor of the container type. * If the value is null return a new indirection object to be used for the attribute. */ public Object validateAttributeOfInstantiatedObject(Object attributeValue) { // PERF: If the value is null, create a new value holder instance for the attribute value, // this allows for indirection attributes to not be instantiated in the constructor as they // are typically replaced when reading or cloning so is very inefficient to initialize. if (attributeValue == null) { return buildIndirectContainer(); } return attributeValue; }
/** * INTERNAL: * Return the value to be stored in the object's attribute. * This value is determined by the query. * In this case, wrap the query in an IndirectContainer for later invocation. */ public Object valueFromQuery(ReadQuery query, AbstractRecord row, AbstractSession session) { return this.buildIndirectContainer(new QueryBasedValueHolder(query, row, session)); }
/** * INTERNAL: * A combination of valueFromQuery and valueFromRow(object). * Sometimes the attribute is known (joining) but we still need to hang on * to the query (pessimistic locking). */ public Object valueFromQuery(ReadQuery query, AbstractRecord row, Object object, AbstractSession session) { return this.buildIndirectContainer(new QueryBasedValueHolder(query, object, row, session)); }
/** * INTERNAL: * A combination of valueFromQuery and valueFromRow(object). * Sometimes the attribute is known (joining) but we still need to hang on * to the query (pessimistic locking). */ public Object valueFromQuery(ReadQuery query, AbstractRecord row, Object object, AbstractSession session) { return this.buildIndirectContainer(new QueryBasedValueHolder(query, object, row, session)); }
/** * INTERNAL: * Return the value to be stored in the object's attribute. * This value is determined by the query. * In this case, wrap the query in an IndirectContainer for later invocation. */ public Object valueFromQuery(ReadQuery query, AbstractRecord row, AbstractSession session) { return this.buildIndirectContainer(new QueryBasedValueHolder(query, row, session)); }
/** * INTERNAL: * Return the value to be stored in the object's attribute. * This value is determined by the query. * In this case, wrap the query in an IndirectContainer for later invocation. */ public Object valueFromQuery(ReadQuery query, AbstractRecord row, AbstractSession session) { return this.buildIndirectContainer(new QueryBasedValueHolder(query, row, session)); }
/** * Return a new IndirectContainer with the specified value holder. */ protected Object buildIndirectContainer(ValueHolderInterface valueHolder) { IndirectContainer result = buildIndirectContainer(); result.setValueHolder(valueHolder); return result; }
/** * Return a new IndirectContainer with the specified value holder. */ protected Object buildIndirectContainer(ValueHolderInterface valueHolder) { IndirectContainer result = buildIndirectContainer(); result.setValueHolder(valueHolder); return result; }
/** * Return a new IndirectContainer with the specified value holder. */ protected Object buildIndirectContainer(ValueHolderInterface valueHolder) { IndirectContainer result = buildIndirectContainer(); result.setValueHolder(valueHolder); return result; }
/** * INTERNAL: * Return the value to be stored in the object's attribute. * This value is determined by the batchQuery. * In this case, wrap the query in an IndirectContainer for later invocation. */ public Object valueFromBatchQuery(ReadQuery batchQuery, AbstractRecord row, ObjectLevelReadQuery originalQuery, CacheKey parentCacheKey) { return this.buildIndirectContainer(new BatchValueHolder(batchQuery, row, getForeignReferenceMapping(), originalQuery, parentCacheKey)); }
/** * INTERNAL: * Return the value to be stored in the object's attribute. * This value is determined by the batchQuery. * In this case, wrap the query in an IndirectContainer for later invocation. */ public Object valueFromBatchQuery(ReadQuery batchQuery, AbstractRecord row, ObjectLevelReadQuery originalQuery, CacheKey parentCacheKey) { return this.buildIndirectContainer(new BatchValueHolder(batchQuery, row, getForeignReferenceMapping(), originalQuery, parentCacheKey)); }
/** * INTERNAL: * Return the original indirection object for a unit of work indirection object. */ @Override public Object getOriginalIndirectionObject(Object unitOfWorkIndirectionObject, AbstractSession session) { IndirectContainer container = (IndirectContainer)unitOfWorkIndirectionObject; if (container.getValueHolder() instanceof UnitOfWorkValueHolder) { return buildIndirectContainer((ValueHolderInterface) getOriginalValueHolder(unitOfWorkIndirectionObject, session)); } else { return container; } }
/** * INTERNAL: * Return the value to be stored in the object's attribute. * This value is determined by the batchQuery. * In this case, wrap the query in an IndirectContainer for later invocation. */ public Object valueFromBatchQuery(ReadQuery batchQuery, AbstractRecord row, ObjectLevelReadQuery originalQuery) { return this.buildIndirectContainer(new BatchValueHolder(batchQuery, row, getForeignReferenceMapping(), originalQuery)); }
/** * INTERNAL: * Return the original indirection object for a unit of work indirection object. */ @Override public Object getOriginalIndirectionObject(Object unitOfWorkIndirectionObject, AbstractSession session) { IndirectContainer container = (IndirectContainer)unitOfWorkIndirectionObject; if (container.getValueHolder() instanceof UnitOfWorkValueHolder) { return buildIndirectContainer((ValueHolderInterface) getOriginalValueHolder(unitOfWorkIndirectionObject, session)); } else { return container; } }
/** * INTERNAL: * Return a backup clone of a clone container that has not been * read from the database yet. * This is used by the indirection policy to hook together a UOW * clone with its backup clone - only when the clone (the working * copy returned to the user) instantiates its contents from the * database will these contents be copied to the backup clone. */ protected Object buildBackupClone(IndirectContainer container) { ValueHolderInterface containerValueHolder = container.getValueHolder(); // CR#2852176 Use a BackupValueHolder to handle replacing of the original. BackupValueHolder backupValueHolder = new BackupValueHolder(containerValueHolder); if (containerValueHolder instanceof UnitOfWorkValueHolder) { ((UnitOfWorkValueHolder) containerValueHolder).setBackupValueHolder(backupValueHolder); } return this.buildIndirectContainer(backupValueHolder); }