public void updateLoaderBehaviour( CFSecurityAuthorization Authorization, CFDbTestLoaderBehaviourBuff Buff) { CFDbTestLoaderBehaviourPKey pkey = schema.getFactoryLoaderBehaviour().newPKey(); pkey.setRequiredId(Buff.getRequiredId()); CFDbTestLoaderBehaviourBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory() .newStaleCacheDetectedException( getClass(), "updateLoaderBehaviour", "Existing record not found", "LoaderBehaviour", pkey); } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory() .newCollisionDetectedException(getClass(), "updateLoaderBehaviour", pkey); } Buff.setRequiredRevision(Buff.getRequiredRevision() + 1); CFDbTestLoaderBehaviourByUNameIdxKey existingKeyUNameIdx = schema.getFactoryLoaderBehaviour().newUNameIdxKey(); existingKeyUNameIdx.setRequiredName(existing.getRequiredName()); CFDbTestLoaderBehaviourByUNameIdxKey newKeyUNameIdx = schema.getFactoryLoaderBehaviour().newUNameIdxKey(); newKeyUNameIdx.setRequiredName(Buff.getRequiredName()); // Check unique indexes if (!existingKeyUNameIdx.equals(newKeyUNameIdx)) { if (dictByUNameIdx.containsKey(newKeyUNameIdx)) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), "updateLoaderBehaviour", "LoaderBehaviourUNameIdx", newKeyUNameIdx); } } // Validate foreign keys // Update is valid Map<CFDbTestLoaderBehaviourPKey, CFDbTestLoaderBehaviourBuff> subdict; dictByPKey.remove(pkey); dictByPKey.put(pkey, Buff); dictByUNameIdx.remove(existingKeyUNameIdx); dictByUNameIdx.put(newKeyUNameIdx, Buff); }
public void deleteLoaderBehaviourByUNameIdx( CFSecurityAuthorization Authorization, CFDbTestLoaderBehaviourByUNameIdxKey argKey) { CFDbTestLoaderBehaviourBuff cur; LinkedList<CFDbTestLoaderBehaviourBuff> matchSet = new LinkedList<CFDbTestLoaderBehaviourBuff>(); Iterator<CFDbTestLoaderBehaviourBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFDbTestLoaderBehaviourBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteLoaderBehaviour(Authorization, cur); } }