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"); }