本文整理了Java中org.jooq.Field.in()
方法的一些代码示例,展示了Field.in()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Field.in()
方法的具体详情如下:
包路径:org.jooq.Field
类名称:Field
方法名:in
[英]Create a condition to check this field against several values.
SQL: this in (values...)
Note that generating dynamic SQL with arbitrary-length IN
predicates can cause cursor cache contention in some databases that use unique SQL strings as a statement identifier (e.g. SQLDialect#ORACLE). In order to prevent such problems, you could use Settings#isInListPadding() to produce less distinct SQL strings (see also #5600(https://github.com/jOOQ/jOOQ/issues/5600)), or you could avoid IN
lists, and replace them with:
IN
predicates on temporary tablesIN
predicates on unnested array bind variablesthis in (values...)
IN
谓词的动态SQL可能会在某些使用唯一SQL字符串作为语句标识符的数据库(例如SQL方言#ORACLE)中导致游标缓存争用。为了防止此类问题,您可以使用设置#isInListPadding()生成不太明显的SQL字符串(另请参见#5600(https://github.com/jOOQ/jOOQ/issues/5600)),或者您可以避免IN
列表,并将其替换为:IN
谓词IN
未赋值数组绑定变量上的谓词代码示例来源:origin: palantir/atlasdb
private Select<? extends Record> getAllTimestampsQuerySomeColumns(DSLContext ctx,
TableReference tableRef,
Select<Record1<byte[]>> subQuery,
Collection<byte[]> cols,
long timestamp) {
return ctx.select(A_ROW_NAME, A_COL_NAME, A_TIMESTAMP)
.from(atlasTable(tableRef).as(ATLAS_TABLE))
.where(A_ROW_NAME.in(subQuery)
.and(A_COL_NAME.in(cols)))
.and(A_TIMESTAMP.lessThan(timestamp));
}
代码示例来源:origin: palantir/atlasdb
private Select<? extends Record> getLatestTimestampQuerySomeColumns(DSLContext ctx,
TableReference tableRef,
Collection<byte[]> rows,
Collection<byte[]> cols,
long timestamp) {
return ctx.select(A_ROW_NAME, A_COL_NAME, DSL.max(A_TIMESTAMP).as(MAX_TIMESTAMP))
.from(atlasTable(tableRef).as(ATLAS_TABLE))
.where(A_ROW_NAME.in(rows)
.and(A_COL_NAME.in(cols)))
.and(A_TIMESTAMP.lessThan(timestamp))
.groupBy(A_ROW_NAME, A_COL_NAME);
}
代码示例来源:origin: palantir/atlasdb
private Select<? extends Record> getLatestTimestampQuerySomeColumnsSubQuery(DSLContext ctx,
TableReference tableRef,
Select<Record1<byte[]>> subQuery,
Collection<byte[]> cols,
long timestamp) {
return ctx.select(A_ROW_NAME, A_COL_NAME, DSL.max(A_TIMESTAMP).as(MAX_TIMESTAMP))
.from(atlasTable(tableRef).as(ATLAS_TABLE))
.where(A_ROW_NAME.in(subQuery)
.and(A_COL_NAME.in(cols)))
.and(A_TIMESTAMP.lessThan(timestamp))
.groupBy(A_ROW_NAME, A_COL_NAME);
}
代码示例来源:origin: palantir/atlasdb
@Override
public void dropTables(final Set<TableReference> tableRefs) throws InsufficientConsistencyException {
if (tableRefs.isEmpty()) {
return;
}
run((Function<DSLContext, Void>) ctx -> {
for (TableReference tableRef : tableRefs) {
ctx.dropTableIfExists(tableName(tableRef)).execute();
}
ctx.deleteFrom(METADATA_TABLE)
.where(TABLE_NAME.in(tableRefs))
.execute();
return null;
});
}
代码示例来源:origin: palantir/atlasdb
private Select<? extends Record> getAllTimestampsQueryAllColumns(DSLContext ctx,
TableReference tableRef,
Select<Record1<byte[]>> subQuery,
long timestamp) {
return ctx.select(A_ROW_NAME, A_COL_NAME, A_TIMESTAMP)
.from(atlasTable(tableRef).as(ATLAS_TABLE))
.where(A_ROW_NAME.in(subQuery)
.and(A_TIMESTAMP.lessThan(timestamp)));
}
代码示例来源:origin: palantir/atlasdb
private Select<? extends Record> getLatestTimestampQueryAllColumnsSubQuery(DSLContext ctx,
TableReference tableRef,
Select<Record1<byte[]>> subQuery,
long timestamp) {
return ctx.select(A_ROW_NAME, A_COL_NAME, DSL.max(A_TIMESTAMP).as(MAX_TIMESTAMP))
.from(atlasTable(tableRef).as(ATLAS_TABLE))
.where(A_ROW_NAME.in(subQuery)
.and(A_TIMESTAMP.lessThan(timestamp)))
.groupBy(A_ROW_NAME, A_COL_NAME);
}
代码示例来源:origin: palantir/atlasdb
private Select<? extends Record> getLatestTimestampQueryAllColumns(DSLContext ctx,
TableReference tableRef,
Collection<byte[]> rows,
long timestamp) {
return ctx.select(A_ROW_NAME, A_COL_NAME, DSL.max(A_TIMESTAMP).as(MAX_TIMESTAMP))
.from(atlasTable(tableRef).as(ATLAS_TABLE))
.where(A_ROW_NAME.in(rows)
.and(A_TIMESTAMP.lessThan(timestamp)))
.groupBy(A_ROW_NAME, A_COL_NAME);
}
代码示例来源:origin: io.github.jklingsporn/vertx-jooq-async-classic
/**
* Find records by a given field and a set of values asynchronously.
*
* @param field The field to compare values against
* @param values The accepted values
* @param resultHandler the resultHandler which succeeds when the blocking method of this type succeeds or fails
* with an <code>DataAccessException</code> if the blocking method of this type throws an exception
* @param <Z> the value type
*/
default <Z> void fetchAsync(Field<Z> field, Collection<Z> values, Handler<AsyncResult<List<P>>> resultHandler){
fetchAsync(field.in(values),resultHandler);
}
代码示例来源:origin: io.github.jklingsporn/vertx-jooq-async-rx
/**
* Find records by a given field and a set of values asynchronously.
*
* @param field The field to compare values against
* @param values The accepted values
* @return Single which succeeds when the blocking method of this type succeeds or fails
* with an <code>DataAccessException</code> if the blocking method of this type throws an exception
*/
default <Z> Single<List<P>> fetchAsync(Field<Z> field, Collection<Z> values) {
return fetchAsync(field.in(values));
}
代码示例来源:origin: io.github.jklingsporn/vertx-jooq-async-future
/**
* Find records by a given field and a set of values asynchronously.
*
* @param field The field to compare values against
* @param values The accepted values
* @param <Z> the value type
* @return CompletableFuture which succeeds when the blocking method of this type succeeds or fails
* with an <code>DataAccessException</code> if the blocking method of this type throws an exception
*/
default <Z> CompletableFuture<List<P>> fetchAsync(Field<Z> field, Collection<Z> values){
return fetchAsync(field.in(values));
}
代码示例来源:origin: jklingsporn/vertx-jooq-async
/**
* Find records by a given field and a set of values asynchronously.
*
* @param field The field to compare values against
* @param values The accepted values
* @param resultHandler the resultHandler which succeeds when the blocking method of this type succeeds or fails
* with an <code>DataAccessException</code> if the blocking method of this type throws an exception
* @param <Z> the value type
*/
default <Z> void fetchAsync(Field<Z> field, Collection<Z> values, Handler<AsyncResult<List<P>>> resultHandler){
fetchAsync(field.in(values),resultHandler);
}
代码示例来源:origin: jklingsporn/vertx-jooq-async
/**
* Find records by a given field and a set of values asynchronously.
*
* @param field The field to compare values against
* @param values The accepted values
* @param <Z> the value type
* @return CompletableFuture which succeeds when the blocking method of this type succeeds or fails
* with an <code>DataAccessException</code> if the blocking method of this type throws an exception
*/
default <Z> CompletableFuture<List<P>> fetchAsync(Field<Z> field, Collection<Z> values){
return fetchAsync(field.in(values));
}
代码示例来源:origin: jklingsporn/vertx-jooq-async
/**
* Find records by a given field and a set of values asynchronously.
*
* @param field The field to compare values against
* @param values The accepted values
* @return Single which succeeds when the blocking method of this type succeeds or fails
* with an <code>DataAccessException</code> if the blocking method of this type throws an exception
*/
default <Z> Single<List<P>> fetchAsync(Field<Z> field, Collection<Z> values) {
return fetchAsync(field.in(values));
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics
private final <U> Condition equal(Field<U> pk, Collection<T> ids) {
if (ids.size() == 1) {
return equal(pk, ids.iterator().next());
}
else {
return pk.in(pk.getDataType().convert(ids));
}
}
代码示例来源:origin: org.jooq/jooq
@SuppressWarnings({ "unchecked" })
@Override
public final Condition isFalse() {
Class<?> type = getType();
if (type == String.class)
return ((Field<String>) this).in(Tools.inline(FALSE_VALUES.toArray(EMPTY_STRING)));
else if (Number.class.isAssignableFrom(type))
return ((Field<Number>) this).equal(inline((Number) getDataType().convert(0)));
else if (Boolean.class.isAssignableFrom(type))
return ((Field<Boolean>) this).equal(inline(false));
else
return cast(String.class).in(Tools.inline(FALSE_VALUES.toArray(EMPTY_STRING)));
}
代码示例来源:origin: org.jooq/jooq
@SuppressWarnings({ "unchecked" })
@Override
public final Condition isTrue() {
Class<?> type = getType();
if (type == String.class)
return ((Field<String>) this).in(Tools.inline(TRUE_VALUES.toArray(EMPTY_STRING)));
else if (Number.class.isAssignableFrom(type))
return ((Field<Number>) this).equal(inline((Number) getDataType().convert(1)));
else if (Boolean.class.isAssignableFrom(type))
return ((Field<Boolean>) this).equal(inline(true));
else
return cast(String.class).in(TRUE_VALUES);
}
代码示例来源:origin: k55k32/cms-admin-end
@Override
public void deleteByIds(Collection<ID> ids) {
getDSLContext().delete(table).where(primaryKey.in(ids)).execute();
}
代码示例来源:origin: mevdschee/java-crud-api
private void addFkRecords(ReflectedTable t2, HashMap<Object, Object> fkValues, Params params, DSLContext dsl,
ArrayList<Record> records) {
Field<Object> pk = t2.getPk();
ArrayList<Field<?>> fields = columns.getNames(t2, false, params);
ResultQuery<org.jooq.Record> query = dsl.select(fields).from(t2).where(pk.in(fkValues.keySet()));
for (org.jooq.Record record : query.fetch()) {
records.add(Record.valueOf(record.intoMap()));
}
}
代码示例来源:origin: org.jooq/jooq
@SuppressWarnings("unchecked")
@Override
public /* non-final */ <Z> List<P> fetch(Field<Z> field, Z... values) {
return using(configuration)
.selectFrom(table)
.where(field.in(values))
.fetch()
.map(mapper());
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics
@Override
public final <Z> List<P> fetch(Field<Z> field, Z... values) {
return using(configuration)
.selectFrom(table)
.where(field.in(values))
.fetch()
.map(mapper());
}
内容来源于网络,如有侵权,请联系作者删除!