includes.addAll(metaModel.getAssociationsForTarget(includeClass));
/** * Deletes immediate children (does not walk the dependency tree). * If you have integrity constraints in the DB that are not accounted * by this call, you will get DB exceptions. * <p> * <h4>One to many and polymorphic associations</h4> * Deletes all child records. * <h4>Many to many associations</h4> * Deletes links in a join table. Nothing else is deleted. * </p> * * @param clazz type of a child to delete */ public <T extends Model> void deleteChildrenShallow(Class<T> clazz) { List<Association> associations = metaModelLocal.getAssociationsForTarget(clazz); for (Association association : associations) { if (association instanceof OneToManyAssociation) { deleteOne2ManyChildrenShallow((OneToManyAssociation) association); }else if(association instanceof Many2ManyAssociation){ deleteManyToManyLinks((Many2ManyAssociation) association); }else if(association instanceof OneToManyPolymorphicAssociation){ deletePolymorphicChildrenShallow((OneToManyPolymorphicAssociation) association); } } }
includes.addAll(metaModel.getAssociationsForTarget(includeClass));
includes.addAll(metaModel.getAssociationsForTarget(Registry.instance().getTableName(includeClass)));
/** * Deletes immediate children (does not walk the dependency tree). * If you have integrity constraints in the DB that are not accounted * by this call, you will get DB exceptions. * <p> * <h4>One to many and polymorphic associations</h4> * Deletes all child records. * <h4>Many to many associations</h4> * Deletes links in a join table. Nothing else is deleted. * </p> * * @param clazz type of a child to delete */ public <T extends Model> void deleteChildrenShallow(Class<T> clazz) { List<Association> associations = metaModelLocal.getAssociationsForTarget(clazz); for (Association association : associations) { if (association instanceof OneToManyAssociation) { deleteOne2ManyChildrenShallow((OneToManyAssociation) association); }else if(association instanceof Many2ManyAssociation){ deleteManyToManyLinks((Many2ManyAssociation) association); }else if(association instanceof OneToManyPolymorphicAssociation){ deletePolymorphicChildrenShallow((OneToManyPolymorphicAssociation) association); } } }