/** * 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, ObjectBuildingQuery query, AbstractSession executionSession) { // Now we are only building this original so we can extract the primary // key out of it. If the primary key is stored accross a 1-1 a value // holder needs to be built/triggered to get at it. // In this case recursively build the shallow original accross the 1-1. // We only need the primary key for that object, and we know // what that primary key is: it is the foreign key in our row. ClassDescriptor descriptor = getReferenceDescriptor(); AbstractRecord targetRow = new DatabaseRecord(); for (Iterator keys = getSourceToTargetKeyFields().keySet().iterator(); keys.hasNext();) { DatabaseField foreignKey = (DatabaseField)keys.next(); DatabaseField targetKey = (DatabaseField)getSourceToTargetKeyFields().get(foreignKey); targetRow.put(targetKey, databaseRow.get(foreignKey)); } Object targetObject = descriptor.getObjectBuilder().buildNewInstance(); descriptor.getObjectBuilder().buildAttributesIntoShallowObject(targetObject, databaseRow, query); targetObject = getIndirectionPolicy().valueFromRow(targetObject); setAttributeValueInObject(original, targetObject); }
/** * Create a new instance, unless a workingCopyClone method is specified, then build a new instance and clone it. */ public Object buildWorkingCopyCloneFromRow(Record row, ObjectBuildingQuery query) throws DescriptorException { // For now must preserve CMP code which builds heavy clones with a context. // Also preserve for clients who use the copy policy. ObjectBuilder builder = getDescriptor().getObjectBuilder(); if (getWorkingCopyMethodName() != null) { Object original = builder.buildNewInstance(); builder.buildAttributesIntoShallowObject(original, (AbstractRecord)row, query); return buildWorkingCopyClone(original, query.getSession()); } else { return builder.buildNewInstance(); } }
descriptor.getObjectBuilder().buildAttributesIntoShallowObject(aggregate, databaseRow, nestedQuery); } else if (session.isUnitOfWork()) { descriptor.getObjectBuilder().buildAttributesIntoWorkingCopyClone(aggregate, nestedQuery, joinManager, databaseRow, (UnitOfWorkImpl)session, refreshing);