Search in sources :

Example 6 with LinkField

use of org.nutz.dao.entity.LinkField in project nutz by nutzam.

the class AbstractJdbcExpert method dropRelation.

public void dropRelation(Dao dao, Entity<?> en) {
    final List<Sql> sqls = new ArrayList<Sql>(5);
    for (LinkField lf : en.visitManyMany(null, null, null)) {
        ManyManyLinkField mm = (ManyManyLinkField) lf;
        if (!dao.exists(mm.getRelationName()))
            continue;
        sqls.add(Sqls.create("DROP TABLE " + mm.getRelationName()));
    }
    dao.execute(sqls.toArray(new Sql[sqls.size()]));
}
Also used : ArrayList(java.util.ArrayList) ManyManyLinkField(org.nutz.dao.impl.entity.field.ManyManyLinkField) ManyManyLinkField(org.nutz.dao.impl.entity.field.ManyManyLinkField) LinkField(org.nutz.dao.entity.LinkField) Sql(org.nutz.dao.sql.Sql)

Aggregations

LinkField (org.nutz.dao.entity.LinkField)6 LinkVisitor (org.nutz.dao.entity.LinkVisitor)3 DoClearLinkVisitor (org.nutz.dao.impl.link.DoClearLinkVisitor)3 DoClearRelationByHostFieldLinkVisitor (org.nutz.dao.impl.link.DoClearRelationByHostFieldLinkVisitor)3 DoClearRelationByLinkedFieldLinkVisitor (org.nutz.dao.impl.link.DoClearRelationByLinkedFieldLinkVisitor)3 DoDeleteLinkVisitor (org.nutz.dao.impl.link.DoDeleteLinkVisitor)3 DoInsertLinkVisitor (org.nutz.dao.impl.link.DoInsertLinkVisitor)3 DoInsertRelationLinkVisitor (org.nutz.dao.impl.link.DoInsertRelationLinkVisitor)3 DoUpdateLinkVisitor (org.nutz.dao.impl.link.DoUpdateLinkVisitor)3 DoUpdateRelationLinkVisitor (org.nutz.dao.impl.link.DoUpdateRelationLinkVisitor)3 ArrayList (java.util.ArrayList)2 ManyManyLinkField (org.nutz.dao.impl.entity.field.ManyManyLinkField)2 Pojo (org.nutz.dao.sql.Pojo)2 Sql (org.nutz.dao.sql.Sql)2 ConditionPItem (org.nutz.dao.impl.sql.pojo.ConditionPItem)1 Criteria (org.nutz.dao.sql.Criteria)1 PItem (org.nutz.dao.sql.PItem)1 SqlExpressionGroup (org.nutz.dao.util.cri.SqlExpressionGroup)1