null, idColumnMapping, keyMapping(manyToManyMapping.getContainerPolicy().getIdentityFieldsForMapKey()), null, null,
null, idColumnMapping, keyMapping(manyToManyMapping.getContainerPolicy().getIdentityFieldsForMapKey()), null, null,
/** * INTERNAL: * Update the relation table with the entries related to this mapping. * Delete entries removed, insert entries added. * If private also insert/delete/update target objects. */ public void postUpdate(WriteObjectQuery query) throws DatabaseException { if (isReadOnly()) { return; } // If objects are not instantiated that means they are not changed. if (!isAttributeValueInstantiatedOrChanged(query.getObject())) { return; } Object objectsInMemoryModel = getRealCollectionAttributeValueFromObject(query.getObject(), query.getSession()); // This accesses the backup in uow otherwise goes to database (may be better of to delete all in non uow case). Object currentObjectsInDB = readPrivateOwnedForObject(query); if (currentObjectsInDB == null) { currentObjectsInDB = getContainerPolicy().containerInstance(1); } compareObjectsAndWrite(currentObjectsInDB, objectsInMemoryModel, query); }
/** * INTERNAL: * An object was added to the collection during an update, insert it. */ protected void insertAddedObjectEntry(ObjectLevelModifyQuery query, Object objectAdded, Map extraData) throws DatabaseException, OptimisticLockException { //cr 3819 added the line below to fix the translationtable to ensure that it // contains the required values prepareTranslationRow(query.getTranslationRow(), query.getObject(), query.getDescriptor(), query.getSession()); AbstractRecord databaseRow = this.mechanism.buildRelationTableSourceAndTargetRow(query.getTranslationRow(), containerPolicy.unwrapIteratorResult(objectAdded), query.getSession(), this); ContainerPolicy.copyMapDataToRow(getContainerPolicy().getKeyMappingDataForWriteQuery(objectAdded, query.getSession()), databaseRow); if(listOrderField != null && extraData != null) { databaseRow.put(listOrderField, extraData.get(listOrderField)); } query.getExecutionSession().executeQuery(this.mechanism.getInsertQuery(), databaseRow); if ((getHistoryPolicy() != null) && getHistoryPolicy().shouldHandleWrites()) { getHistoryPolicy().mappingLogicalInsert(this.mechanism.getInsertQuery(), databaseRow, query.getSession()); } }
/** * INTERNAL: * An object was added to the collection during an update, insert it. */ protected void insertAddedObjectEntry(ObjectLevelModifyQuery query, Object objectAdded, Map extraData) throws DatabaseException, OptimisticLockException { //cr 3819 added the line below to fix the translationtable to ensure that it // contains the required values prepareTranslationRow(query.getTranslationRow(), query.getObject(), query.getSession()); AbstractRecord databaseRow = this.mechanism.buildRelationTableSourceAndTargetRow(query.getTranslationRow(), containerPolicy.unwrapIteratorResult(objectAdded), query.getSession(), this); ContainerPolicy.copyMapDataToRow(getContainerPolicy().getKeyMappingDataForWriteQuery(objectAdded, query.getSession()), databaseRow); if(listOrderField != null && extraData != null) { databaseRow.put(listOrderField, extraData.get(listOrderField)); } query.getSession().executeQuery(this.mechanism.getInsertQuery(), databaseRow); if ((getHistoryPolicy() != null) && getHistoryPolicy().shouldHandleWrites()) { getHistoryPolicy().mappingLogicalInsert(this.mechanism.getInsertQuery(), databaseRow, query.getSession()); } }
/** * INTERNAL: * An object was added to the collection during an update, insert it. */ protected void insertAddedObjectEntry(ObjectLevelModifyQuery query, Object objectAdded, Map extraData) throws DatabaseException, OptimisticLockException { //cr 3819 added the line below to fix the translationtable to ensure that it // contains the required values prepareTranslationRow(query.getTranslationRow(), query.getObject(), query.getDescriptor(), query.getSession()); AbstractRecord databaseRow = this.mechanism.buildRelationTableSourceAndTargetRow(query.getTranslationRow(), containerPolicy.unwrapIteratorResult(objectAdded), query.getSession(), this); ContainerPolicy.copyMapDataToRow(getContainerPolicy().getKeyMappingDataForWriteQuery(objectAdded, query.getSession()), databaseRow); if(listOrderField != null && extraData != null) { databaseRow.put(listOrderField, extraData.get(listOrderField)); } query.getExecutionSession().executeQuery(this.mechanism.getInsertQuery(), databaseRow); if ((getHistoryPolicy() != null) && getHistoryPolicy().shouldHandleWrites()) { getHistoryPolicy().mappingLogicalInsert(this.mechanism.getInsertQuery(), databaseRow, query.getSession()); } }
/** * INTERNAL: * An object was removed to the collection during an update, delete it if private. */ protected void objectRemovedDuringUpdate(ObjectLevelModifyQuery query, Object objectDeleted, Map extraData) throws DatabaseException, OptimisticLockException { Object unwrappedObjectDeleted = getContainerPolicy().unwrapIteratorResult(objectDeleted); AbstractRecord databaseRow = this.mechanism.buildRelationTableSourceAndTargetRow(query.getTranslationRow(), unwrappedObjectDeleted, query.getSession(), this); // In the uow data queries are cached until the end of the commit. if (query.shouldCascadeOnlyDependentParts()) { // Hey I might actually want to use an inner class here... ok array for now. Object[] event = new Object[3]; event[0] = ObjectRemoved; event[1] = this.mechanism.getDeleteQuery(); event[2] = databaseRow; query.getSession().getCommitManager().addDataModificationEvent(this, event); } else { query.getSession().executeQuery(this.mechanism.getDeleteQuery(), databaseRow); if ((getHistoryPolicy() != null) && getHistoryPolicy().shouldHandleWrites()) { getHistoryPolicy().mappingLogicalDelete(this.mechanism.getDeleteQuery(), databaseRow, query.getSession()); } } // Delete object after join entry is delete if private. super.objectRemovedDuringUpdate(query, objectDeleted, extraData); }
/** * INTERNAL: * An object was removed to the collection during an update, delete it if private. */ @Override protected void objectRemovedDuringUpdate(ObjectLevelModifyQuery query, Object objectDeleted, Map extraData) throws DatabaseException, OptimisticLockException { Object unwrappedObjectDeleted = getContainerPolicy().unwrapIteratorResult(objectDeleted); AbstractRecord databaseRow = this.mechanism.buildRelationTableSourceAndTargetRow(query.getTranslationRow(), unwrappedObjectDeleted, query.getSession(), this); // In the uow data queries are cached until the end of the commit. if (query.shouldCascadeOnlyDependentParts()) { // Hey I might actually want to use an inner class here... ok array for now. Object[] event = new Object[3]; event[0] = ObjectRemoved; event[1] = this.mechanism.getDeleteQuery(); event[2] = databaseRow; query.getSession().getCommitManager().addDataModificationEvent(this, event); } else { query.getSession().executeQuery(this.mechanism.getDeleteQuery(), databaseRow); if ((getHistoryPolicy() != null) && getHistoryPolicy().shouldHandleWrites()) { getHistoryPolicy().mappingLogicalDelete(this.mechanism.getDeleteQuery(), databaseRow, query.getSession()); } } // Delete object after join entry is delete if private. super.objectRemovedDuringUpdate(query, objectDeleted, extraData); }
/** * INTERNAL: * An object was removed to the collection during an update, delete it if private. */ @Override protected void objectRemovedDuringUpdate(ObjectLevelModifyQuery query, Object objectDeleted, Map extraData) throws DatabaseException, OptimisticLockException { Object unwrappedObjectDeleted = getContainerPolicy().unwrapIteratorResult(objectDeleted); AbstractRecord databaseRow = this.mechanism.buildRelationTableSourceAndTargetRow(query.getTranslationRow(), unwrappedObjectDeleted, query.getSession(), this); // In the uow data queries are cached until the end of the commit. if (query.shouldCascadeOnlyDependentParts()) { // Hey I might actually want to use an inner class here... ok array for now. Object[] event = new Object[3]; event[0] = ObjectRemoved; event[1] = this.mechanism.getDeleteQuery(); event[2] = databaseRow; query.getSession().getCommitManager().addDataModificationEvent(this, event); } else { query.getSession().executeQuery(this.mechanism.getDeleteQuery(), databaseRow); if ((getHistoryPolicy() != null) && getHistoryPolicy().shouldHandleWrites()) { getHistoryPolicy().mappingLogicalDelete(this.mechanism.getDeleteQuery(), databaseRow, query.getSession()); } } // Delete object after join entry is delete if private. super.objectRemovedDuringUpdate(query, objectDeleted, extraData); }
ContainerPolicy containerPolicy = getContainerPolicy();
AbstractSession session = query.getSession(); Object objectsIterator = null; ContainerPolicy containerPolicy = getContainerPolicy();
AbstractSession session = query.getSession(); Object objectsIterator = null; ContainerPolicy containerPolicy = getContainerPolicy();
ContainerPolicy cp = getContainerPolicy(); Object objects = getRealCollectionAttributeValueFromObject(query.getObject(), query.getSession()); if (cp.isEmpty(objects)) {
ContainerPolicy cp = getContainerPolicy(); Object objects = getRealCollectionAttributeValueFromObject(query.getObject(), query.getSession()); if (cp.isEmpty(objects)) {
ContainerPolicy cp = getContainerPolicy(); Object objects = getRealCollectionAttributeValueFromObject(query.getObject(), query.getSession()); if (cp.isEmpty(objects)) {
ContainerPolicy cp = getContainerPolicy(); if (cp.isEmpty(objects)) { return;
ContainerPolicy cp = getContainerPolicy(); if (cp.isEmpty(objects)) { return;
ContainerPolicy cp = getContainerPolicy(); if (cp.isEmpty(objects)) { return;