本文整理汇总了Java中org.jooq.ResultQuery类的典型用法代码示例。如果您正苦于以下问题:Java ResultQuery类的具体用法?Java ResultQuery怎么用?Java ResultQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResultQuery类属于org.jooq包,在下文中一共展示了ResultQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Select
import org.jooq.ResultQuery; //导入依赖的package包/类
private Select(
Connection connection,
QueryBuilder<ResultQuery<? extends R>> queryBuilder,
RecordMapper<? super R, ? extends T> recordMapper
) {
super(
subscriber -> {
try (ResultQuery<? extends R> query = queryBuilder.build(connection)) {
Cursor<? extends R> cursor = query.fetchLazy();
setupUnsubscription(subscriber, query, cursor);
log.debug("Select setProducer for {}", query);
subscriber.setProducer(new SelectProducer<>(
subscriber,
query,
cursor,
recordMapper
));
} catch (Throwable t) {
handleException(t, subscriber);
}
}
);
}
示例2: cleanupServiceEventTable
import org.jooq.ResultQuery; //导入依赖的package包/类
private void cleanupServiceEventTable(Date cutoff) {
ResultQuery<Record1<Long>> ids = create()
.select(SERVICE_EVENT.ID)
.from(SERVICE_EVENT)
.where(SERVICE_EVENT.CREATED.lt(cutoff))
.and(SERVICE_EVENT.STATE.eq(CommonStatesConstants.CREATED))
.limit(QUERY_LIMIT_ROWS.getValue());
List<Long> toDelete = null;
int rowsDeleted = 0;
while ((toDelete = ids.fetch().into(Long.class)).size() > 0) {
rowsDeleted += create().delete(SERVICE_EVENT)
.where(SERVICE_EVENT.ID.in(toDelete)).execute();
}
if (rowsDeleted > 0) {
log.info("[Rows Deleted] service_event={}", rowsDeleted);
}
}
示例3: select
import org.jooq.ResultQuery; //导入依赖的package包/类
@SuppressWarnings(value={"unused"})
private int select (String tableName, List<String> rows, List<String> columns) {
Timer timer = Timer.start ("flat-dataset");
Table<Record> table = tableByName (tableName);
List<Field<String>> selectFields = createFieldList (columns);
ResultQuery<Record> query;
List<String> rowKeys = getRowKeys (tableName, ID_FIELD_NAME);
if (rowKeys.size () == rows.size ())
query = queryAllRows (selectFields, table);
else {
query = queryINRows (tableName, selectFields, rows);
}
int count = read (query);
timer.read ();
return count;
}
示例4: fetchList
import org.jooq.ResultQuery; //导入依赖的package包/类
private List<String> fetchList (ResultQuery<Record1<String>> query, String columnField) {
Cursor<Record1<String>> cursor = null;
List<String> result = new ArrayList<String> (1000);
try {
cursor = query.fetchLazy ();
// Cursor has similar methods as Iterator<R>
while (cursor.hasNext ()) {
Record record = cursor.fetchOne ();
String sValue = (String) record.getValue (columnField);
result.add (sValue);
}
} finally {
if (cursor != null) {
cursor.close ();
}
}
return result;
}
示例5: getRowKeys
import org.jooq.ResultQuery; //导入依赖的package包/类
@Synchronized @SuppressWarnings("unused")
private List<String> getRowKeys (String tableName, String fieldRowIdName) {
Timer timer = Timer.start ("get-row-keys");
if (this.rowKeys == null) {
Table<Record> table = tableByName (tableName);
Field<String> fieldRowId = fieldByName (String.class, fieldRowIdName);
// get rows
Timer timer2 = Timer.start ("fetch-array");
ResultQuery<Record1<String>> queryRowKeys = context.select (fieldRowId).from (table).getQuery ();
String[] arows = queryRowKeys.fetchArray (fieldRowId);
timer2.read ();
// List<String> rows = Arrays.asList (arows);
timer2 = Timer.start ("copy-array-to-list");
// this.rowKeys = new ArrayList<String>(arows.length);
// Collections.addAll (this.rowKeys, arows);
// this.rowKeys = Arrays.asList (arows);
this.rowKeys = fetchList (queryRowKeys, ID_FIELD_NAME);
timer2.read ();
log.debug ("rows.size(): " + this.rowKeys.size ());
}
timer.read ();
return this.rowKeys;
}
示例6: select
import org.jooq.ResultQuery; //导入依赖的package包/类
@SuppressWarnings(value={"unused"})
private int select(String tableName, List<String> rows, List<String> columns){
Timer timer = Timer.start ("flat-dataset");
Table<Record> table = tableByName (tableName);
List<Field<String>> selectFields = createFieldList (columns);
ResultQuery<Record> query;
List<String> rowKeys = getRowKeys (tableName, ID_FIELD_NAME);
if(rowKeys.size ()==rows.size ())
query = queryAllRows (selectFields, table);
else{
query = queryINRows (tableName, selectFields, rows);
}
int count = read(query);
timer.read ();
return count;
}
示例7: select
import org.jooq.ResultQuery; //导入依赖的package包/类
@SuppressWarnings(value={"unused"})
private int select (String tableName, List<String> rows, List<String> columns) {
Timer timer = Timer.start ("flat-dataset");
Table<Record> table = tableByName (tableName);
Field<String> fieldRowId = fieldByName (String.class, ID_FIELD_NAME);
List<Field<String>> selectFields = createFieldList (columns);
ResultQuery<Record> query;
List<String> rowKeys = getRowKeys (tableName, ID_FIELD_NAME);
if (rowKeys.size () == rows.size ())
query = queryAllRows (selectFields, table);
else {
query = queryINRows (tableName, selectFields, rows);
}
int count = read (query);
timer.read ();
return count;
}
示例8: getRowKeys
import org.jooq.ResultQuery; //导入依赖的package包/类
@Synchronized
private List<String> getRowKeys(String tableName, String fieldRowIdName){
if(rowCasche.containsKey (tableName)){
return rowCasche.get (tableName);
}else{
Table<Record> table = tableByName (tableName);
Field<String> fieldRowId = fieldByName (String.class, fieldRowIdName);
//get rows
Timer timer = Timer.start ("get-row-keys");
ResultQuery<Record1<String>> queryRowKeys =context.select(fieldRowId).from(table).orderBy (fieldRowId).getQuery ();
String[] arows = queryRowKeys.fetchArray (fieldRowId);
timer.read ("fetch-array");
// List<String> rows = Arrays.asList (arows);
List<String> rows = new ArrayList<String>(arows.length);
Collections.addAll (rows, arows);
timer.read ("collection");
if(log.isDebugEnabled ()){
timer.read();
log.debug ("rows.size(): " + rows.size ());
}
rowCasche.put (tableName, rows);
return rows;
}
}
示例9: getColumnKeys
import org.jooq.ResultQuery; //导入依赖的package包/类
private List<String> getColumnKeys(String tableName, String fieldRowIdName){
//get columns
Table<Record> table = tableByName (tableName);
Timer timer = Timer.start ("get-column-keys");
ResultQuery<Record> queryColumnKeys =context.selectFrom(table).limit (1) .getQuery ();
Record recordColumnKeys = queryColumnKeys.fetchOne ();
List<String> columns = new ArrayList<String>();
for(Field<?> field : recordColumnKeys.fields())
if(!field.getName ().equals (ID_FIELD_NAME))
columns.add (field.getName ());
if(log.isDebugEnabled ()){
timer.read();
log.debug ("columns.size(): " + columns.size ());
log.debug ("columns: " + columns);
}
return columns;
}
示例10: getAsStream
import org.jooq.ResultQuery; //导入依赖的package包/类
@Override
public InputStream getAsStream (Dimension dimension) {
// SelectQuery<Tables> query = context.selectQuery()
Table<?> table = tableByName (TABLE_NAME_PREFIX+this.platformId ());
Field<String> probeId = fieldByName (String.class, "PROBESET_ID");
InputStream input=null;
ResultQuery<?> query = context.selectFrom(table)
.where(probeId.in (dimension.keys ()));
log.debug(query.toString ());
String csv = query.fetch().formatCSV('\t');
try {
input = new ByteArrayInputStream (csv.getBytes ("UTF-8"));
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return input;
}
示例11: SelectProducer
import org.jooq.ResultQuery; //导入依赖的package包/类
public SelectProducer(
Subscriber<? super T> subscriber,
ResultQuery<? extends R> query,
Cursor<? extends R> cursor,
RecordMapper<? super R, ? extends T> recordMapper
) {
this.subscriber = subscriber;
this.query = query;
this.cursor = cursor;
this.recordMapper = recordMapper;
}
示例12: setupUnsubscription
import org.jooq.ResultQuery; //导入依赖的package包/类
private static <R extends Record, T> void setupUnsubscription(
Subscriber<? super T> subscriber,
ResultQuery<? extends R> query,
Cursor<? extends R> cursor
) {
subscriber.add(
Subscriptions.create(
() -> {
closeQuietly(cursor);
closeQuietly(query);
}
)
);
}
示例13: limit
import org.jooq.ResultQuery; //导入依赖的package包/类
private ResultQuery<Record> limit(Integer startPos, Integer maxRows, SelectSeekStep1<Record, Timestamp> selectSeekStep) {
if (maxRows != null) {
if (startPos == null) {
startPos = 0;
}
return selectSeekStep.limit(startPos, maxRows);
} else {
return selectSeekStep;
}
}
示例14: toQuery
import org.jooq.ResultQuery; //导入依赖的package包/类
protected ResultQuery<?> toQuery(Class<?> clz, Map<Object, Object> values) {
String type = schemaFactory.getSchemaName(clz);
if (type == null) {
throw new IllegalArgumentException("Failed to find type of class [" + clz + "]");
}
Class<UpdatableRecord<?>> recordClass = JooqUtils.getRecordClass(schemaFactory, clz);
Table<?> table = JooqUtils.getTableFromRecordClass(recordClass);
return create().selectFrom(table).where(JooqUtils.toConditions(metaDataManager, type, values));
}
示例15: toQuery
import org.jooq.ResultQuery; //导入依赖的package包/类
protected ResultQuery<?> toQuery(Class<?> clz, Map<Object, Object> values) {
String type = schemaFactory.getSchemaName(clz);
if ( type == null ) {
throw new IllegalArgumentException("Failed to find type of class [" + clz + "]");
}
Class<UpdatableRecord<?>> recordClass = JooqUtils.getRecordClass(schemaFactory, clz);
Table<?> table = JooqUtils.getTableFromRecordClass(recordClass);
return create()
.selectFrom(table)
.where(JooqUtils.toConditions(metaDataManager, type, values));
}