/** * INTERNAL: * Build and return a new instance of the specified attribute. * This will be populated by a merge. */ protected Object buildNewMergeInstanceOf(Object sourceAttributeValue, AbstractSession session) { return getObjectBuilder(sourceAttributeValue, session).buildNewInstance(); }
/** * By default create a new instance. */ public Object buildWorkingCopyCloneFromRow(Record row, ObjectBuildingQuery query) throws DescriptorException { return getDescriptor().getObjectBuilder().buildNewInstance(); }
public Object buildClone(Object domainObject, Session session) throws DescriptorException { return getDescriptor().getObjectBuilder().buildNewInstance(); }
/** * 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(); } }
/** * PUBLIC: * Return a new instance of the class registered in this unit of work. * This can be used to ensure that new objects are registered correctly. */ public Object newInstance(Class theClass) { //CR#2272 logDebugMessage(theClass, "new_instance"); ClassDescriptor descriptor = getDescriptor(theClass); Object newObject = descriptor.getObjectBuilder().buildNewInstance(); return registerObject(newObject); }
/** * INTERNAL: * Return the backup clone for the working clone. */ public Object getBackupCloneForCommit(Object clone) { Object backupClone = getBackupClone(clone); /* CR3440: Steven Vo * Build new instance only if it was not handled by getBackupClone() */ if (isCloneNewObject(clone)) { return getDescriptor(clone).getObjectBuilder().buildNewInstance(); } return backupClone; }
targetAggregate = objectBuilder.buildNewInstance(); } else { if ((sourceAggregate != null) && (sourceAggregate.getClass() != targetAggregate.getClass())) { targetAggregate = objectBuilder.buildNewInstance();
/** * 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); }
Object original = builder.buildNewInstance(); Object backupClone = builder.buildNewInstance(); getCloneMapping().put(newObject, backupClone); assignSequenceNumber(newObject);
/** * INTERNAL: * setup the modifyQuery for post insert/update and pre delete */ public InsertObjectQuery getAndPrepareModifyQueryForInsert(ObjectLevelModifyQuery originalQuery, Object object) { AbstractSession session = originalQuery.getSession(); ClassDescriptor objReferenceDescriptor = getReferenceDescriptor(object.getClass(), session); InsertObjectQuery insertQueryFromDescriptor = getInsertObjectQuery(session, objReferenceDescriptor); insertQueryFromDescriptor.checkPrepare(session, insertQueryFromDescriptor.getModifyRow()); InsertObjectQuery insertQuery = (InsertObjectQuery)insertQueryFromDescriptor.clone(); insertQuery.setObject(object); AbstractRecord targetForeignKeyRow = new DatabaseRecord(); Vector referenceObjectKeys = getReferenceObjectKeys(originalQuery); for (int keyIndex = 0; keyIndex < getTargetForeignKeyFields().size(); keyIndex++) { targetForeignKeyRow.put(getTargetForeignKeyFields().elementAt(keyIndex), referenceObjectKeys.elementAt(keyIndex)); } insertQuery.setModifyRow(targetForeignKeyRow); insertQuery.setTranslationRow(targetForeignKeyRow); insertQuery.setSession(session); insertQuery.setCascadePolicy(originalQuery.getCascadePolicy()); insertQuery.dontMaintainCache(); // For bug 2863721 must set a backup clone for compatibility with // old event mechanism, even though for AggregateCollections there is no // way to get a backup directly from a clone. if (session.isUnitOfWork()) { Object backupAttributeValue = getReferenceDescriptor(object.getClass(), session).getObjectBuilder().buildNewInstance(); insertQuery.setBackupClone(backupAttributeValue); } return insertQuery; }
Object original = builder.buildNewInstance(); Object backupClone = builder.buildNewInstance(); getCloneMapping().put(implementation, backupClone);
Object backupAttributeValue = getMatchingBackupAttributeValue(query, attributeValue); if (backupAttributeValue == null) { backupAttributeValue = getObjectBuilder(attributeValue, query.getSession()).buildNewInstance();
/** * Clone through calling the clone method. */ public Object buildClone(Object domainObject, Session session) throws DescriptorException { // Must allow for null clone method for 9.0.4 deployment XML. if (this.getMethodName() == null) { return getDescriptor().getObjectBuilder().buildNewInstance(); } try { if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ try { return AccessController.doPrivileged(new PrivilegedMethodInvoker(this.getMethod(), domainObject, new Object[0])); } catch (PrivilegedActionException exception) { Exception throwableException = exception.getException(); if (throwableException instanceof IllegalAccessException) { throw DescriptorException.illegalAccessWhileCloning(domainObject, this.getMethodName(), this.getDescriptor(), throwableException); } else { throw DescriptorException.targetInvocationWhileCloning(domainObject, this.getMethodName(), this.getDescriptor(), throwableException); } } } else { return PrivilegedAccessHelper.invokeMethod(this.getMethod(), domainObject, new Object[0]); } } catch (IllegalAccessException exception) { throw DescriptorException.illegalAccessWhileCloning(domainObject, this.getMethodName(), this.getDescriptor(), exception); } catch (InvocationTargetException exception) { throw DescriptorException.targetInvocationWhileCloning(domainObject, this.getMethodName(), this.getDescriptor(), exception); } }
/** * Initialize the aggregate query with the settings from the source query. */ protected void buildAggregateModifyQuery(ObjectLevelModifyQuery sourceQuery, ObjectLevelModifyQuery aggregateQuery, Object sourceAttributeValue) { if (sourceQuery.getSession().isUnitOfWork()) { Object backupAttributeValue = getAttributeValueFromBackupClone(sourceQuery.getBackupClone()); if (backupAttributeValue == null) { backupAttributeValue = getObjectBuilder(sourceAttributeValue, sourceQuery.getSession()).buildNewInstance(); } aggregateQuery.setBackupClone(backupAttributeValue); } aggregateQuery.setCascadePolicy(sourceQuery.getCascadePolicy()); aggregateQuery.setObject(sourceAttributeValue); aggregateQuery.setTranslationRow(sourceQuery.getTranslationRow()); aggregateQuery.setSession(sourceQuery.getSession()); aggregateQuery.setProperties(sourceQuery.getProperties()); }
return descriptor.getObjectBuilder().buildNewInstance(); backupClone = descriptor.getObjectBuilder().buildNewInstance();
targetAggregate = getReferenceDescriptor(localClassType, session).getObjectBuilder().buildNewInstance();
Object originalValue = getReferenceDescriptor(sourceValue.getClass(), mergeManager.getSession()).getObjectBuilder().buildNewInstance(); getReferenceDescriptor(sourceValue.getClass(), mergeManager.getSession()).getObjectBuilder().mergeIntoObject(originalValue, true, sourceValue, mergeManager); containerPolicy.addInto(originalValue, valueOfTarget, mergeManager.getSession());
object = mergeManager.getSession().getDescriptor(objectClass).getObjectBuilder().buildNewInstance();
object = descriptor.getObjectBuilder().buildNewInstance();
targetValueOfSource = mergeManager.getSession().getDescriptor(objectClass).getObjectBuilder().buildNewInstance();