/** * Return whether any process leading to object modification * should also affect its parts. * Used by write, insert, update, and delete. */ protected boolean shouldObjectModifyCascadeToParts(ObjectLevelModifyQuery query) { if (isReadOnly()) { return false; } if (isPrivateOwned()) { return true; } if (containerPolicy.isMappedKeyMapPolicy()){ return true; } return query.shouldCascadeAllParts(); }
/** * Return whether any process leading to object modification * should also affect its parts. * Used by write, insert, update, and delete. */ @Override protected boolean shouldObjectModifyCascadeToParts(ObjectLevelModifyQuery query) { if (isReadOnly()) { return false; } if (isPrivateOwned()) { return true; } if (containerPolicy.isMappedKeyMapPolicy() && containerPolicy.requiresDataModificationEvents()){ return true; } return query.shouldCascadeAllParts(); }
/** * Return whether any process leading to object modification * should also affect its parts. * Used by write, insert, update, and delete. */ @Override protected boolean shouldObjectModifyCascadeToParts(ObjectLevelModifyQuery query) { if (isReadOnly()) { return false; } if (isPrivateOwned()) { return true; } if (containerPolicy.isMappedKeyMapPolicy() && containerPolicy.requiresDataModificationEvents()){ return true; } return query.shouldCascadeAllParts(); }
/** * INTERNAL: * Update target foreign key after a target object was added to the source. This follows following steps. * <p>- Extract primary key and its value from the source object. * <p>- Extract target key and its value from the target object. * <p>- Construct an update statement with above fields and values for target table. * <p>- execute the statement. */ public void updateTargetForeignKeyPostUpdateSource_ObjectAdded(ObjectLevelModifyQuery query, Object objectAdded, Map extraData) throws DatabaseException { if (isReadOnly()) { return; } ContainerPolicy cp = getContainerPolicy(); prepareTranslationRow(query.getTranslationRow(), query.getObject(), query.getSession()); AbstractRecord databaseRow = buildKeyRowForTargetUpdate(query); // Extract target field and its value. Construct insert statement and execute it int size = targetPrimaryKeyFields.size(); for (int index = 0; index < size; index++) { DatabaseField targetPrimaryKey = targetPrimaryKeyFields.get(index); Object targetKeyValue = getReferenceDescriptor().getObjectBuilder().extractValueFromObjectForField(cp.unwrapIteratorResult(objectAdded), targetPrimaryKey, query.getSession()); databaseRow.put(targetPrimaryKey, targetKeyValue); } ContainerPolicy.copyMapDataToRow(cp.getKeyMappingDataForWriteQuery(objectAdded, query.getSession()), databaseRow); if(listOrderField != null && extraData != null) { databaseRow.put(listOrderField, extraData.get(listOrderField)); } query.getSession().executeQuery(addTargetQuery, databaseRow); }
/** * INTERNAL: * Update the reference objects. */ public void postUpdate(WriteObjectQuery query) throws DatabaseException, OptimisticLockException { if (isReadOnly()) { return; } if (!requiresDataModificationEvents() && !shouldObjectModifyCascadeToParts(query)){ return; } // if the target objects are not instantiated, they could not have been changed.... if (!isAttributeValueInstantiatedOrChanged(query.getObject())) { return; } // manage objects added and removed from the collection Object objectsInMemory = getRealCollectionAttributeValueFromObject(query.getObject(), query.getSession()); Object objectsInDB = readPrivateOwnedForObject(query); compareObjectsAndWrite(objectsInDB, objectsInMemory, query); }
/** * INTERNAL: * Update target foreign key after a target object was added to the source. This follows following steps. * <p>- Extract primary key and its value from the source object. * <p>- Extract target key and its value from the target object. * <p>- Construct an update statement with above fields and values for target table. * <p>- execute the statement. */ public void updateTargetForeignKeyPostUpdateSource_ObjectAdded(ObjectLevelModifyQuery query, Object objectAdded, Map extraData) throws DatabaseException { if (isReadOnly() || addTargetQuery == null) { return; } ContainerPolicy cp = getContainerPolicy(); prepareTranslationRow(query.getTranslationRow(), query.getObject(), query.getDescriptor(), query.getSession()); AbstractRecord databaseRow = buildKeyRowForTargetUpdate(query); // Extract target field and its value. Construct insert statement and execute it int size = targetPrimaryKeyFields.size(); for (int index = 0; index < size; index++) { DatabaseField targetPrimaryKey = targetPrimaryKeyFields.get(index); Object targetKeyValue = getReferenceDescriptor().getObjectBuilder().extractValueFromObjectForField(cp.unwrapIteratorResult(objectAdded), targetPrimaryKey, query.getSession()); databaseRow.put(targetPrimaryKey, targetKeyValue); } ContainerPolicy.copyMapDataToRow(cp.getKeyMappingDataForWriteQuery(objectAdded, query.getSession()), databaseRow); if(listOrderField != null && extraData != null) { databaseRow.put(listOrderField, extraData.get(listOrderField)); } query.getSession().executeQuery(addTargetQuery, databaseRow); }
/** * INTERNAL: * Update target foreign key after a target object was added to the source. This follows following steps. * <p>- Extract primary key and its value from the source object. * <p>- Extract target key and its value from the target object. * <p>- Construct an update statement with above fields and values for target table. * <p>- execute the statement. */ public void updateTargetForeignKeyPostUpdateSource_ObjectAdded(ObjectLevelModifyQuery query, Object objectAdded, Map extraData) throws DatabaseException { if (isReadOnly() || addTargetQuery == null) { return; } ContainerPolicy cp = getContainerPolicy(); prepareTranslationRow(query.getTranslationRow(), query.getObject(), query.getDescriptor(), query.getSession()); AbstractRecord databaseRow = buildKeyRowForTargetUpdate(query); // Extract target field and its value. Construct insert statement and execute it int size = targetPrimaryKeyFields.size(); for (int index = 0; index < size; index++) { DatabaseField targetPrimaryKey = targetPrimaryKeyFields.get(index); Object targetKeyValue = getReferenceDescriptor().getObjectBuilder().extractValueFromObjectForField(cp.unwrapIteratorResult(objectAdded), targetPrimaryKey, query.getSession()); databaseRow.put(targetPrimaryKey, targetKeyValue); } ContainerPolicy.copyMapDataToRow(cp.getKeyMappingDataForWriteQuery(objectAdded, query.getSession()), databaseRow); if(listOrderField != null && extraData != null) { databaseRow.put(listOrderField, extraData.get(listOrderField)); } query.getSession().executeQuery(addTargetQuery, databaseRow); }
if (isReadOnly() || addTargetQuery == null) { return;
if (isReadOnly() || addTargetQuery == null) { return;
if (isReadOnly()) { return; if (!isReadOnly() && (requiresDataModificationEvents() || containerPolicy.shouldUpdateForeignKeysPostInsert())) { if (!isReadOnly() && (requiresDataModificationEvents() || containerPolicy.shouldUpdateForeignKeysPostInsert())){ updateTargetRowPostInsertSource(query);
if (isReadOnly()) { return; if (!isReadOnly() && (requiresDataModificationEvents() || containerPolicy.shouldUpdateForeignKeysPostInsert())) { if (!isReadOnly() && (requiresDataModificationEvents() || containerPolicy.shouldUpdateForeignKeysPostInsert())){ updateTargetRowPostInsertSource(query);