本文整理了Java中org.jooq.TableField.plus()
方法的一些代码示例,展示了TableField.plus()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TableField.plus()
方法的具体详情如下:
包路径:org.jooq.TableField
类名称:TableField
方法名:plus
暂无
代码示例来源:origin: rancher/cattle
protected boolean increment(Client client, String itemName) {
int updated = create()
.update(CONFIG_ITEM_STATUS)
.set(CONFIG_ITEM_STATUS.REQUESTED_VERSION, CONFIG_ITEM_STATUS.REQUESTED_VERSION.plus(1))
.set(CONFIG_ITEM_STATUS.REQUESTED_UPDATED, new Timestamp(System.currentTimeMillis()))
.where(
CONFIG_ITEM_STATUS.NAME.eq(itemName)
.and(targetObjectCondition(client))).execute();
return updated > 0;
}
代码示例来源:origin: com.walmartlabs.concord.server/concord-server
private int[] update(DSLContext tx, Connection conn, List<HostItem> hosts) throws SQLException {
Field<Integer> currentStatusWeight = decodeStatus(choose(ANSIBLE_HOSTS.STATUS));
Field<Integer> newStatusWeight = decodeStatus(choose(value((String) null)));
String update = tx.update(ANSIBLE_HOSTS)
.set(ANSIBLE_HOSTS.DURATION, ANSIBLE_HOSTS.DURATION.plus(value((Integer) null)))
.set(ANSIBLE_HOSTS.STATUS, when(currentStatusWeight.greaterThan(newStatusWeight), ANSIBLE_HOSTS.STATUS).otherwise(value((String) null)))
.set(ANSIBLE_HOSTS.EVENT_SEQ, when(currentStatusWeight.greaterThan(newStatusWeight), ANSIBLE_HOSTS.EVENT_SEQ).otherwise(value((Long) null)))
.where(ANSIBLE_HOSTS.INSTANCE_ID.eq(value((UUID) null))
.and(ANSIBLE_HOSTS.INSTANCE_CREATED_AT.eq(value((Timestamp) null))
.and(ANSIBLE_HOSTS.HOST.eq(value((String) null))
.and(ANSIBLE_HOSTS.HOST_GROUP.eq(value((String) null))))))
.getSQL();
try (PreparedStatement ps = conn.prepareStatement(update)) {
for (HostItem h : hosts) {
ps.setLong(1, h.duration());
ps.setString(2, h.status());
ps.setString(3, h.status());
ps.setString(4, h.status());
ps.setLong(5, h.eventSeq());
ps.setObject(6, h.key().instanceId());
ps.setTimestamp(7, h.key().instanceCreatedAt());
ps.setString(8, h.key().host());
ps.setString(9, h.key().hostGroup());
ps.addBatch();
}
return ps.executeBatch();
}
}
代码示例来源:origin: rancher/cattle
@Override
public Long incrementRevision(long accountId) {
Record1<Long> row = create().select(ACCOUNT.REVISION)
.from(ACCOUNT)
.where(ACCOUNT.ID.eq(accountId))
.fetchAny();
if (row == null) {
return 0L;
}
create().update(ACCOUNT)
.set(ACCOUNT.REVISION, ACCOUNT.REVISION.plus(1))
.where(ACCOUNT.ID.eq(accountId))
.execute();
return row.value1() + 1;
}
}
代码示例来源:origin: com.walmartlabs.concord.server/concord-server
public List<TimedOutEntry> pollExpired(DSLContext tx, int maxEntries) {
ProcessQueue q = PROCESS_QUEUE.as("q");
@SuppressWarnings("unchecked")
Field<? extends Number> i = (Field<? extends Number>) interval("1 second");
return tx.select(q.INSTANCE_ID, q.CREATED_AT, q.LAST_AGENT_ID, q.TIMEOUT)
.from(q)
.where(q.CURRENT_STATUS.eq(ProcessStatus.RUNNING.toString())
.and(q.LAST_RUN_AT.plus(q.TIMEOUT.mul(i)).lessOrEqual(currentTimestamp())))
.orderBy(q.CREATED_AT)
.limit(maxEntries)
.forUpdate()
.skipLocked()
.fetch(WatchdogDao::toExpiredEntry);
}
代码示例来源:origin: com.walmartlabs.concord.server/concord-server
public synchronized long inc(UUID projectId, String key) {
ProjectKvStore kv = PROJECT_KV_STORE.as("kv");
return txResult(tx -> {
// grab a lock, it will be released when the transaction ends
tx.execute("select from pg_advisory_xact_lock(?)", hash(projectId, key));
// "upsert" the record
tx.insertInto(kv)
.columns(kv.PROJECT_ID, kv.VALUE_KEY, kv.VALUE_LONG)
.values(projectId, key, 1L)
.onConflict(kv.PROJECT_ID, kv.VALUE_KEY)
.doUpdate().set(kv.VALUE_LONG, kv.VALUE_LONG.plus(1))
.execute();
// get an updated value
return tx.select(kv.VALUE_LONG)
.from(kv)
.where(kv.PROJECT_ID.eq(projectId)
.and(kv.VALUE_KEY.eq(key)))
.fetchOne(kv.VALUE_LONG);
});
}
代码示例来源:origin: com.walmartlabs.concord.server/concord-server
public List<String> poll() {
@SuppressWarnings("unchecked")
Field<? extends Number> i = (Field<? extends Number>) PgUtils.interval("1 second");
return txResult(tx -> {
List<String> ids = tx.select(TASKS.TASK_ID)
.from(TASKS)
.where(TASKS.TASK_INTERVAL.greaterThan(0L).and(TASKS.STARTED_AT.isNull()
.or(TASKS.FINISHED_AT.isNotNull()
.and(TASKS.FINISHED_AT.plus(TASKS.TASK_INTERVAL.mul(i)).lessOrEqual(currentTimestamp())))))
.forUpdate()
.skipLocked()
.fetch(TASKS.TASK_ID);
if (ids.isEmpty()) {
return ids;
}
tx.update(TASKS)
.set(TASKS.STARTED_AT, currentTimestamp())
.set(TASKS.TASK_STATUS, value("RUNNING"))
.set(TASKS.FINISHED_AT, (Timestamp)null)
.set(TASKS.LAST_UPDATED_AT, currentTimestamp())
.where(TASKS.TASK_ID.in(ids))
.execute();
return ids;
});
}
内容来源于网络,如有侵权,请联系作者删除!