private void deleteChildrenDeep(List<? extends Association> childAssociations){ for (Association association : childAssociations) { String targetTableName = metaModelOf(association.getTargetClass()).getTableName(); Class c = Registry.instance().getModelClass(targetTableName, false); if(c == null){// this model is probably not defined as a class, but the table exists! LogFilter.log(LOGGER, LogLevel.ERROR, "ActiveJDBC WARNING: failed to find a model class for: {}, maybe model is not defined for this table?" + " There might be a risk of running into integrity constrain violation if this model is not defined.", targetTableName); } else{ List<Model> dependencies = getAll(c); for (Model model : dependencies) { model.deleteCascade(); } } } }
/** * Checks if there is association to the target model class., * * @param targetModelClass class of a model that will be checked for association from current model. * @return true if any association exists such that the current model is a source and targetModelClass is a target. */ public boolean isAssociatedTo(Class<? extends Model> targetModelClass) { for (Association association : associations) { Class targetClass = Registry.instance().getModelClass(association.getTarget(), true); if (targetClass != null && targetClass.equals(targetModelClass)) { return true; } } return false; } }
private void deleteMany2ManyDeep(List<Many2ManyAssociation> many2ManyAssociations){ List<Model> allMany2ManyChildren = new ArrayList<Model>(); for (Association association : many2ManyAssociations) { String targetTableName = association.getTarget(); Class c = Registry.instance().getModelClass(targetTableName, false); if(c == null){// this model is probably not defined as a class, but the table exists! logger.error("ActiveJDBC WARNING: failed to find a model class for: {}, maybe model is not defined for this table?" + " There might be a risk of running into integrity constrain violation if this model is not defined.", targetTableName); } else{ allMany2ManyChildren.addAll(getAll(c)); } } deleteJoinsForManyToMany(); for (Model model : allMany2ManyChildren) { model.deleteCascade(); } }
private void deleteChildrenDeep(List<? extends Association> childAssociations){ for (Association association : childAssociations) { String targetTableName = association.getTarget(); Class c = Registry.instance().getModelClass(targetTableName, false); if(c == null){// this model is probably not defined as a class, but the table exists! logger.error("ActiveJDBC WARNING: failed to find a model class for: {}, maybe model is not defined for this table?" + " There might be a risk of running into integrity constrain violation if this model is not defined.", targetTableName); } else{ List<Model> dependencies = getAll(c); for (Model model : dependencies) { model.deleteCascade(); } } } }
private void deleteChildrenDeep(List<? extends Association> childAssociations){ for (Association association : childAssociations) { String targetTableName = metaModelOf(association.getTargetClass()).getTableName(); Class c = Registry.instance().getModelClass(targetTableName, false); if(c == null){// this model is probably not defined as a class, but the table exists! LogFilter.log(LOGGER, LogLevel.ERROR, "ActiveJDBC WARNING: failed to find a model class for: {}, maybe model is not defined for this table?" + " There might be a risk of running into integrity constrain violation if this model is not defined.", targetTableName); } else{ List<Model> dependencies = getAll(c); for (Model model : dependencies) { model.deleteCascade(); } } } }