/** * Clear associated models' save state. After this method, the associated models of baseObj which * data is removed from database will become unsaved. * * @param baseObj The record to delete. * @param associationInfos The associated info. */ private void clearAssociatedModelSaveState( DataSupport baseObj, Collection<AssociationsInfo> associationInfos) { try { for (AssociationsInfo associationInfo : associationInfos) { if (associationInfo.getAssociationType() == Const.Model.MANY_TO_ONE && !baseObj.getClassName().equals(associationInfo.getClassHoldsForeignKey())) { Collection<DataSupport> associatedModels = getAssociatedModels(baseObj, associationInfo); if (associatedModels != null && !associatedModels.isEmpty()) { for (DataSupport model : associatedModels) { if (model != null) { model.resetBaseObjId(); } } } } else if (associationInfo.getAssociationType() == Const.Model.ONE_TO_ONE) { DataSupport model = getAssociatedModel(baseObj, associationInfo); if (model != null) { model.resetBaseObjId(); } } } } catch (Exception e) { throw new DataSupportException(e.getMessage()); } }