/** * INTERNAL: * Builds a shallow original object. Only direct attributes and primary * keys are populated. In this way the minimum original required for * instantiating a working copy clone can be built without placing it in * the shared cache (no concern over cycles). */ public void buildShallowOriginalFromRow(AbstractRecord databaseRow, Object original, JoinedAttributeManager joinManager, AbstractSession executionSession) { Object aggregate = buildAggregateFromRow(databaseRow, original, joinManager, true, executionSession);// shallow only. setAttributeValueInObject(original, aggregate); }
/** * INTERNAL: * Build an aggregate object from the specified row and put it * in the specified target object. */ public Object readFromRowIntoObject(AbstractRecord databaseRow, JoinedAttributeManager joinManager, Object targetObject, ObjectBuildingQuery sourceQuery, AbstractSession executionSession) throws DatabaseException { Object aggregate = buildAggregateFromRow(databaseRow, targetObject, joinManager, false, executionSession);// don't just build a shallow original setAttributeValueInObject(targetObject, aggregate); return aggregate; }
/** * INTERNAL: * Clone the attribute from the original and assign it to the clone. */ public void buildClone(Object original, Object clone, UnitOfWorkImpl unitOfWork) { Object attributeValue = getAttributeValueFromObject(original); Object aggregateClone = buildClonePart(original, attributeValue, unitOfWork); if (aggregateClone != null) { ClassDescriptor descriptor = getReferenceDescriptor(aggregateClone, unitOfWork); descriptor.getObjectChangePolicy().setAggregateChangeListener(clone, aggregateClone, unitOfWork, descriptor, getAttributeName()); } setAttributeValueInObject(clone, aggregateClone); }
/** * INTERNAL: * A combination of readFromRowIntoObject and buildClone. * <p> * buildClone assumes the attribute value exists on the original and can * simply be copied. * <p> * readFromRowIntoObject assumes that one is building an original. * <p> * Both of the above assumptions are false in this method, and actually * attempts to do both at the same time. * <p> * Extract value from the row and set the attribute to this value in the * working copy clone. * In order to bypass the shared cache when in transaction a UnitOfWork must * be able to populate working copies directly from the row. */ public void buildCloneFromRow(AbstractRecord databaseRow, JoinedAttributeManager joinManager, Object clone, ObjectBuildingQuery sourceQuery, UnitOfWorkImpl unitOfWork, AbstractSession executionSession) { // This method is a combination of buildggregateFromRow and // buildClonePart on the super class. // none of buildClonePart used, as not an orignal new object, nor // do we worry about creating heavy clones for aggregate objects. Object clonedAttributeValue = buildAggregateFromRow(databaseRow, clone, joinManager, false, executionSession); ClassDescriptor descriptor = getReferenceDescriptor(clonedAttributeValue, unitOfWork); descriptor.getObjectChangePolicy().setAggregateChangeListener(clone, clonedAttributeValue, unitOfWork, descriptor, getAttributeName()); setAttributeValueInObject(clone, clonedAttributeValue); return; }
setAttributeValueInObject(targetObject, aggregate);