本文整理了Java中com.j256.ormlite.stmt.Where.countOf()
方法的一些代码示例,展示了Where.countOf()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Where.countOf()
方法的具体详情如下:
包路径:com.j256.ormlite.stmt.Where
类名称:Where
方法名:countOf
[英]A short-cut for calling QueryBuilder#countOf().
[中]调用QueryBuilder#countOf()的捷径。
代码示例来源:origin: org.mycontroller.standalone/mycontroller-core
@SuppressWarnings("unchecked")
public long countOf(String key, Object data) {
try {
if (data instanceof List) {
return this.getDao().queryBuilder().where().in(key, ((List<Object>) data)).countOf();
} else {
return this.getDao().queryBuilder().where().eq(key, data).countOf();
}
} catch (SQLException ex) {
_logger.error("unable to get count key:{}, data:{}", key, data, ex);
return 0;
}
}
代码示例来源:origin: geeksonsecurity/android-overlay-protection
@Override
public void onClick(View v) {
try {
// Add entry and update cache
Dao<WhiteEntry, Integer> whiteListDao = _helper.getWhiteListDao();
long duplicate = whiteListDao.queryBuilder().where().eq("name", offenderName).countOf();
if (duplicate == 0) {
WhiteEntry we = new WhiteEntry(offenderName, System.currentTimeMillis(), 1, false, true);
whiteListDao.create(we);
_whiteEntries.add(we);
Log.i(TAG,
String.format("Added user white list entry for %s", we.getName()));
} else {
Log.w(TAG, String.format("White entry %s already in DB", offenderName));
}
} catch (SQLException e) {
Log.e(TAG,
String.format("Failed to update white list entry for %s", offenderName), e);
}
windowManager.removeViewImmediate(oView);
state.resetState();
}
});
代码示例来源:origin: mycontroller-org/mycontroller
@SuppressWarnings("unchecked")
public long countOf(String key, Object data) {
try {
if (data instanceof List) {
return this.getDao().queryBuilder().where().in(key, ((List<Object>) data)).countOf();
} else {
return this.getDao().queryBuilder().where().eq(key, data).countOf();
}
} catch (SQLException ex) {
_logger.error("unable to get count key:{}, data:{}", key, data, ex);
throw new McDatabaseException(ex);
}
}
代码示例来源:origin: geeksonsecurity/android-overlay-protection
cal.add(Calendar.MONTH, -1);
try {
final long overlayCount = qb.where().between("timestamp", cal.getTimeInMillis(), System.currentTimeMillis()).countOf();
final String overlayCountLabel = String.format(getString(R.string.detectedCount), overlayCount);
代码示例来源:origin: org.mycontroller.standalone/mycontroller-core
@Override
public long countOf(AGGREGATION_TYPE aggregationType, long start, long end) {
QueryBuilder<MetricsBatteryUsage, Object> queryBuilder = getDao().queryBuilder();
try {
return queryBuilder.where().gt(MetricsBatteryUsage.KEY_TIMESTAMP, start).and()
.le(MetricsBatteryUsage.KEY_TIMESTAMP, end).and()
.eq(MetricsBatteryUsage.KEY_AGGREGATION_TYPE, aggregationType).countOf();
} catch (Exception ex) {
_logger.error("Unable to execute countOf query", ex);
return -1;
}
}
代码示例来源:origin: org.mycontroller.standalone/mycontroller-core
@Override
public long countOf(AGGREGATION_TYPE aggregationType, long start, long end) {
QueryBuilder<MetricsCounterTypeDevice, Object> queryBuilder = getDao().queryBuilder();
try {
return queryBuilder.where().gt(MetricsCounterTypeDevice.KEY_TIMESTAMP, start).and()
.le(MetricsCounterTypeDevice.KEY_TIMESTAMP, end).and()
.eq(MetricsCounterTypeDevice.KEY_AGGREGATION_TYPE, aggregationType).countOf();
} catch (Exception ex) {
_logger.error("Unable to execute countOf query", ex);
return -1;
}
}
代码示例来源:origin: org.mycontroller.standalone/mycontroller-core
@Override
public long countOf(AGGREGATION_TYPE aggregationType, long start, long end) {
QueryBuilder<MetricsDoubleTypeDevice, Object> queryBuilder = getDao().queryBuilder();
try {
return queryBuilder.where().gt(MetricsDoubleTypeDevice.KEY_TIMESTAMP, start).and()
.le(MetricsDoubleTypeDevice.KEY_TIMESTAMP, end).and()
.eq(MetricsDoubleTypeDevice.KEY_AGGREGATION_TYPE, aggregationType).countOf();
} catch (Exception ex) {
_logger.error("Unable to execute countOf query", ex);
return -1;
}
}
代码示例来源:origin: mycontroller-org/mycontroller
@Override
public long countOf(AGGREGATION_TYPE aggregationType, long start, long end) {
QueryBuilder<MetricsDoubleTypeDevice, Object> queryBuilder = getDao().queryBuilder();
try {
return queryBuilder.where().gt(MetricsDoubleTypeDevice.KEY_TIMESTAMP, start).and()
.le(MetricsDoubleTypeDevice.KEY_TIMESTAMP, end).and()
.eq(MetricsDoubleTypeDevice.KEY_AGGREGATION_TYPE, aggregationType).countOf();
} catch (Exception ex) {
_logger.error("Unable to execute countOf query", ex);
throw new McDatabaseException(ex);
}
}
代码示例来源:origin: mycontroller-org/mycontroller
@Override
public long countOf(AGGREGATION_TYPE aggregationType, long start, long end) {
QueryBuilder<MetricsCounterTypeDevice, Object> queryBuilder = getDao().queryBuilder();
try {
return queryBuilder.where().gt(MetricsCounterTypeDevice.KEY_TIMESTAMP, start).and()
.le(MetricsCounterTypeDevice.KEY_TIMESTAMP, end).and()
.eq(MetricsCounterTypeDevice.KEY_AGGREGATION_TYPE, aggregationType).countOf();
} catch (Exception ex) {
_logger.error("Unable to execute countOf query", ex);
throw new McDatabaseException(ex);
}
}
代码示例来源:origin: mycontroller-org/mycontroller
@Override
public long countOf(AGGREGATION_TYPE aggregationType, long start, long end) {
QueryBuilder<MetricsBatteryUsage, Object> queryBuilder = getDao().queryBuilder();
try {
return queryBuilder.where().gt(MetricsBatteryUsage.KEY_TIMESTAMP, start).and()
.le(MetricsBatteryUsage.KEY_TIMESTAMP, end).and()
.eq(MetricsBatteryUsage.KEY_AGGREGATION_TYPE, aggregationType).countOf();
} catch (Exception ex) {
_logger.error("Unable to execute countOf query", ex);
throw new McDatabaseException(ex);
}
}
内容来源于网络,如有侵权,请联系作者删除!