/** * INTERNAL: * Returns whether the mapping has any constraint dependencies, such as * join table entries. This dependency is important for deletes from * unidirectional relationships. */ public boolean hasConstraintDependency() { // Set a dependency on the owning side return !isReadOnly(); }
/** * INTERNAL: * The join table is a dependency if not read-only. */ public boolean hasDependency() { return isPrivateOwned() || (!isReadOnly()); }
/** * Return whether any process leading to object deletion should also affect its parts. * Used in preDelete. Note that dependencies are reversed for deletes: * Join table entries must be removed before the related objects can be deleted. * So the owning side must be deleted before the non-owning side is processed. */ protected boolean shouldObjectModifyCascadeToPartsForPreDelete(ObjectLevelModifyQuery query) { // Always cascade for privately-owned parts if (isPrivateOwned()) { return true; } // The non-owning side is read-only for join table mappings. if (query.shouldCascadeOnlyDependentParts()) { return isReadOnly(); } return query.shouldCascadeAllParts(); } }
/** * 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 (!isAttributeValueInstantiated(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); }
if (isReadOnly()) { return;
if (!isReadOnly()) { prepareTranslationRow(query.getTranslationRow(), query.getObject(), query.getSession()); query.getSession().executeQuery(getDeleteAllQuery(), query.getTranslationRow());