本文整理了Java中org.jooq.Field.as()
方法的一些代码示例,展示了Field.as()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Field.as()
方法的具体详情如下:
包路径:org.jooq.Field
类名称:Field
方法名:as
[英]Create an alias for this field.
Note that the case-sensitivity of the returned field depends on Settings#getRenderNameStyle(). By default, field aliases are quoted, and thus case-sensitive!
[中]为此字段创建别名。
请注意,返回字段的大小写敏感度取决于设置#getRenderNameStyle()。默认情况下,字段别名被引用,因此区分大小写!
代码示例来源:origin: org.jooq/jooq
static final Field<?>[] aliasedFields(Field<?>[] fields, Name[] aliases) {
if (fields == null)
return null;
Field<?>[] result = new Field[fields.length];
for (int i = 0; i < fields.length; i++)
result[i] = fields[i].as(aliases[i]);
return result;
}
代码示例来源:origin: palantir/atlasdb
TableLike<?> values(DSLContext ctx, RowN[] rows, String tableName, String... fieldNames) {
switch (sqlDialect.family()) {
case H2:
List<SelectField<?>> fields = Lists.newArrayListWithCapacity(fieldNames.length);
for (int i = 1; i <= fieldNames.length; i++) {
fields.add(DSL.field("C" + i).as(fieldNames[i-1]));
}
RenderContext context = ctx.renderContext();
context.start(TABLE_VALUES)
.keyword("values")
.formatIndentLockStart();
boolean firstRow = true;
for (Row row : rows) {
if (!firstRow) {
context.sql(',').formatSeparator();
}
context.sql(row.toString());
firstRow = false;
}
context.formatIndentLockEnd()
.end(TABLE_VALUES);
String valuesClause = context.render();
return ctx.select(fields).from(valuesClause).asTable(tableName);
default:
return DSL.values(rows).as(tableName, fieldNames);
}
}
代码示例来源:origin: org.jooq/jooq
@Override
public final <T> Field<T> asField(String alias) {
return this.<T> asField().as(alias);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics
@Override
public final <T> Field<T> asField(String alias) {
return this.<T> asField().as(alias);
}
代码示例来源:origin: org.jooq/jooq
@Override
public <T> Field<T> asField(Function<? super Field<T>, ? extends String> aliasFunction) {
return this.<T> asField().as(aliasFunction);
}
代码示例来源:origin: org.jooq/jooq
@Override
public final Field<T> as(Name as) {
return alias.wrapped().as(as);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics
@Override
public final Field<T> as(String as) {
return alias.wrapped().as(as);
}
代码示例来源:origin: org.jooq/jooq
public final Field<T> asField(String alias) {
return asField().as(alias);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics
public final Field<T> asField(String alias) {
return asField().as(alias);
}
代码示例来源:origin: com.torodb.torod.backends/common
private SortedSet<Field<?>> completeFields(SortedSet<Field<?>> columns, SubDocTable subDocTable) {
SortedSet<Field<?>> fields = Sets.newTreeSet(columns.comparator());
for (Field<?> column : columns) {
if (subDocTable.field(column.getName()) != null) {
fields.add(subDocTable.field(column));
} else {
fields.add(DSL.castNull(column.getDataType()).as(column));
}
}
return fields;
}
代码示例来源:origin: mevdschee/java-crud-api
public ArrayList<Field<?>> getNames(ReflectedTable table, boolean primaryTable, Params params) {
ArrayList<Field<?>> columns = new ArrayList<>();
for (String key : columns(table, primaryTable, params)) {
Field<?> field = table.get(key);
if (field.getDataType().getTypeName().equals("geometry")) {
columns.add(SpatialDSL.asText(field).as(key));
} else {
columns.add(field);
}
}
return columns;
}
代码示例来源:origin: rancher/cattle
public MultiTableMapper map(String name, Table<?> table) {
boolean emptyPrefix = name.equals("");
TableMapping mapping = new TableMapping();
String prefix = emptyPrefix ? "" : "table" + mappings.size() + "_";
mapping.originalTable = table;
mapping.keyName = name;
mapping.prefix = prefix;
mapping.aliasedTable = table.as(mapping.prefix + table.getName());
mapping.originalFields = table.fields();
mapping.aliasedFields = new Field<?>[mapping.originalFields.length];
Field<?>[] unaliasedFields = mapping.aliasedTable.fields();
for (int i = 0; i < mapping.aliasedFields.length; i++) {
Field<?> field = unaliasedFields[i];
Field<?> alias = emptyPrefix ? field : field.as(prefix + field.getName());
mapping.aliasedFields[i] = alias;
fieldsMapping.put(alias.getName(), mapping);
fields.add(alias);
}
tables.add(mapping.aliasedTable);
mappings.put(mapping.keyName, mapping);
return this;
}
代码示例来源:origin: rancher/cattle
@SuppressWarnings({ "unchecked", "hiding" })
public <T extends Table<?>> T add(T input, Field<?>... selectedFields) {
Set<String> selectFields = selectedFields == null || selectedFields.length == 0 ? null : new HashSet<String>();
int index = count++;
String prefix = String.format("%s_%d", input.getName(), index);
Table<?> alias = input.as(prefix);
for (Field<?> field : selectedFields) {
selectFields.add(field.getName());
}
for (Field<?> field : alias.fields()) {
if (selectFields != null && !"id".equals(field.getName()) && !selectFields.contains(field.getName())) {
continue;
}
String fieldAlias = String.format("%s_%s", prefix, field.getName());
Target target = new Target(field.getName(), index);
targets.put(fieldAlias, target);
fields.add(field.as(String.format("%s_%s", prefix, field.getName())));
}
classes.add(input.getRecordType());
return (T) alias;
}
代码示例来源:origin: com.walmartlabs.concord.server/concord-server
public Instant now() {
return txResult(tx -> tx.select(currentTimestamp().as("now"))
.fetchOne(field("now", Timestamp.class))
.toInstant());
}
代码示例来源:origin: org.jooq/jooq
private static final List<SelectFieldOrAsterisk> parseSelectList(ParserContext ctx) {
List<SelectFieldOrAsterisk> result = new ArrayList<SelectFieldOrAsterisk>();
do {
if (peekKeyword(ctx, KEYWORDS_IN_SELECT))
throw ctx.exception("Select keywords must be quoted");
QualifiedAsterisk qa;
if (parseIf(ctx, '*')) {
result.add(DSL.asterisk());
}
else if ((qa = parseQualifiedAsteriskIf(ctx)) != null) {
result.add(qa);
}
else {
Field<?> field = parseField(ctx);
Name alias = null;
if (parseKeywordIf(ctx, "AS"))
alias = parseIdentifier(ctx, true);
else if (!peekKeyword(ctx, KEYWORDS_IN_SELECT))
alias = parseIdentifierIf(ctx, true);
result.add(alias == null ? field : field.as(alias));
}
}
while (parseIf(ctx, ','));
return result;
}
代码示例来源:origin: org.jooq/jooq
@SuppressWarnings({ "serial", "unchecked", "rawtypes" })
RowField(final ROW row, Name as) {
super(as, (DataType) SQLDataType.RECORD, CommentImpl.NO_COMMENT, binding(new Converter<Object, REC>() {
@Override
public REC from(final Object t) {
// So far, this is only supported for PostgreSQL
return (REC) (t == null ? null : pgNewRecord(Record.class, row.fields(), t));
}
@Override
public Object to(REC u) {
throw new UnsupportedOperationException("Converting from nested records to bind values is not yet supported");
}
@Override
public Class<Object> fromType() {
return Object.class;
}
@Override
public Class<REC> toType() {
return (Class<REC>) RecordImpl.class;
}
}));
this.row = row;
this.emulatedFields = new Field[row.fields().length];
for (int i = 0; i < emulatedFields.length; i++)
emulatedFields[i] = row.field(i).as(as + "." + row.field(i).getName());
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics
private final Table<Record> table(Configuration configuration) {
if (table == null) {
Select<Record> select = null;
for (Object element : array) {
// [#1081] Be sure to get the correct cast type also for null
Field<?> val = DSL.val(element, field.fields[0].getDataType());
Select<Record> subselect = using(configuration).select(val.as("COLUMN_VALUE")).select();
if (select == null) {
select = subselect;
}
else {
select = select.unionAll(subselect);
}
}
// Empty arrays should result in empty tables
if (select == null) {
select = using(configuration).select(one().as("COLUMN_VALUE")).select().where(falseCondition());
}
table = select.asTable(alias);
}
return table;
}
}
代码示例来源:origin: com.walmartlabs.concord.server/concord-server
@WithTimer
public int getDepth(UUID parentInstanceId) {
return txResult(tx -> tx.withRecursive("ancestors").as(
select(PROCESS_QUEUE.INSTANCE_ID, PROCESS_QUEUE.PARENT_INSTANCE_ID, field("1", Integer.class).as("depth"))
.from(PROCESS_QUEUE)
.where(PROCESS_QUEUE.INSTANCE_ID.eq(parentInstanceId))
.unionAll(
select(PROCESS_QUEUE.INSTANCE_ID, PROCESS_QUEUE.PARENT_INSTANCE_ID, field("1 + ancestors.depth", Integer.class).as("depth"))
.from(PROCESS_QUEUE)
.join(name("ancestors"))
.on(PROCESS_QUEUE.INSTANCE_ID.eq(
field(name("ancestors", "PARENT_INSTANCE_ID"), UUID.class)))))
.select(max(field(name("ancestors", "depth"), Integer.class)))
.from(name("ancestors"))
.fetchOne(Record1::value1));
}
}
代码示例来源:origin: org.jooq/jooq-meta
private Result<Record3<String, String, String>> fetchKeys(Condition condition) {
return
create().select(
concat(DB_CLASS.CLASS_NAME, val("__"), DB_INDEX.INDEX_NAME).as("constraint_name"),
DB_INDEX_KEY.KEY_ATTR_NAME,
DB_CLASS.CLASS_NAME)
.from(DB_INDEX)
.join(DB_CLASS).on(DB_INDEX.CLASS_NAME.equal(DB_CLASS.CLASS_NAME))
.join(DB_INDEX_KEY).on(
DB_INDEX_KEY.INDEX_NAME.equal(DB_INDEX.INDEX_NAME).and(
DB_INDEX_KEY.CLASS_NAME.equal(DB_INDEX.CLASS_NAME)))
.where(condition)
.orderBy(
DB_INDEX.INDEX_NAME.asc())
.fetch();
}
代码示例来源:origin: org.jooq/jooq
private final Table<Record> table(Configuration configuration) {
if (table == null) {
Select<Record> select = null;
for (Object element : array) {
// [#1081] Be sure to get the correct cast type also for null
Field<?> val = DSL.val(element, field.fields[0].getDataType());
Select<Record> subselect = using(configuration).select(val.as("COLUMN_VALUE")).select();
if (select == null) {
select = subselect;
}
else {
select = select.unionAll(subselect);
}
}
// Empty arrays should result in empty tables
if (select == null) {
select = using(configuration).select(one().as("COLUMN_VALUE")).select().where(falseCondition());
}
table = DSL.table(select).as(alias);
}
return table;
}
}
内容来源于网络,如有侵权,请联系作者删除!