XUtil学习之DBUtil(十二)

来源:互联网 发布:淘宝开放平台 top 编辑:程序博客网 时间:2024/06/05 06:13

没看上篇博客的请查看XUtil学习之DBUtil(十一)

统计

(1)count(Selector selector)

 public long count(Selector selector) throws DbException {        Class<?> entityType = selector.getEntityType();        if (!tableIsExist(entityType)) return 0;        Table table = Table.get(this, entityType);        DbModelSelector dmSelector = selector.select("count(" + table.id.getColumnName() + ") as count");        return findDbModelFirst(dmSelector).getLong("count");    }

(2)count(Class<> entityType)

public long count(Class<?> entityType) throws DbException {        return count(Selector.from(entityType));    }
0 0