org.jooq.Table类的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(185)

本文整理了Java中org.jooq.Table类的一些代码示例,展示了Table类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Table类的具体详情如下:
包路径:org.jooq.Table
类名称:Table

Table介绍

[英]A table to be used in queries
[中]用于查询的表

代码示例

代码示例来源:origin: my2iu/Jinq

@Override
public int getNumColumns()
{
 return table.fields().length;
}

代码示例来源:origin: palantir/atlasdb

@Override
public void delete(final TableReference tableRef, final Multimap<Cell, Long> keys) {
  if (keys.isEmpty()) {
    return;
  }
  for (List<Entry<Cell, Long>> partition : Iterables.partition(keys.entries(), batchSizeForMutations)) {
    run((Function<DSLContext, Void>) ctx -> {
      Collection<Row3<byte[], byte[], Long>> rows = Lists.newArrayListWithCapacity(partition.size());
      for (Entry<Cell, Long> entry : partition) {
        rows.add(row(entry.getKey().getRowName(), entry.getKey().getColumnName(), entry.getValue()));
      }
      ctx.deleteFrom(atlasTable(tableRef).as(ATLAS_TABLE))
          .where(row(A_ROW_NAME, A_COL_NAME, A_TIMESTAMP).in(rows))
          .execute();
      return null;
    });
  }
}

代码示例来源:origin: my2iu/Jinq

@Override
public T readResult(Record record, int offset)
{
 T toReturn;
 try {
   toReturn = constructor.newInstance();
 } catch (Exception e) {
   throw new IllegalArgumentException("Cannot construct class " + table.getRecordType().getName());
 }
 Field<?>[] fields = table.fields(); 
 for (int idx = 0; idx < fields.length; idx++)
 {
   Field<?> f = fields[idx];
   copyValueIntoRecord(toReturn, record, f, idx);
 }
 return toReturn;
}

代码示例来源:origin: palantir/atlasdb

int endIndex = partialSql.lastIndexOf(')');
String fullSql = partialSql.substring(0, endIndex) + "," +
    " CONSTRAINT pk_" + kvs.METADATA_TABLE.getName() +
    " PRIMARY KEY (" + TABLE_NAME.getName() + ")" +
    partialSql.substring(endIndex);

代码示例来源:origin: org.jooq/jooq

if (!StringUtils.isBlank(t.getCatalog().getName()))
  it.setTableCatalog(t.getCatalog().getName());
if (!StringUtils.isBlank(t.getSchema().getName()))
  it.setTableSchema(t.getSchema().getName());
it.setTableName(t.getName());
it.setComment(t.getComment());
result.getTables().add(it);
Field<?>[] fields = t.fields();
for (int i = 0; i < fields.length; i++) {
  Field<?> f = fields[i];
  Column ic = new Column();
  if (!StringUtils.isBlank(t.getCatalog().getName()))
    ic.setTableCatalog(t.getCatalog().getName());
  if (!StringUtils.isBlank(t.getSchema().getName()))
    ic.setTableSchema(t.getSchema().getName());
  ic.setTableName(t.getName());
  ic.setColumnName(f.getName());
  ic.setComment(f.getComment());
for (UniqueKey<?> key : t.getKeys())
  exportKey0(result, t, key, key.isPrimary() ? PRIMARY_KEY : UNIQUE);
for (ForeignKey<?, ?> fk : t.getReferences())

代码示例来源:origin: com.torodb.torod.backends/common

public boolean isSemanticallyEquals(Table<Record> table) {
  if (!table.getName().equals(getName())) {
    return false;
  }
  if (table.getSchema() == null || !getSchema().getName().equals(table.getSchema().getName())) {
    return false;
  }
  if (table.fields().length != 7) {
    return false;
  }
  return true; //TODO: improve the check
}

代码示例来源:origin: org.jooq/jooq

@Override
public final LoaderImpl<R> onDuplicateKeyUpdate() {
  if (table.getPrimaryKey() == null) {
    throw new IllegalStateException("ON DUPLICATE KEY UPDATE only works on tables with explicit primary keys. Table is not updatable : " + table);
  }
  onDuplicate = ON_DUPLICATE_KEY_UPDATE;
  return this;
}

代码示例来源:origin: mevdschee/java-crud-api

@SuppressWarnings("unchecked")
public ReflectedTable(Table<?> table) {
  super(table.getQualifiedName());
  this.table = table;
  for (Field<?> field : table.fields()) {
    String name = field.getName();
    DataType<Object> dataType = (DataType<Object>) field.getDataType();
    TableField newField = createField(name, dataType);
    fields.put(name, newField);
  }
  UniqueKey<?> primaryKey = table.getPrimaryKey();
  if (primaryKey != null) {
    if (primaryKey.getFields().size() == 1) {
      pk = primaryKey.getFields().get(0);
    }
  }
  for (ForeignKey<?, ?> fk : table.getReferences()) {
    fks.put(findForeignKeyFieldName(fk), findForeignKeyReference(fk));
  }
}

代码示例来源:origin: perfectsense/dari

private SqlSubJoin(SqlQuery parent, SqlQuery sub, SqlJoin join) {
    this.sqlQuery = sub;

    AbstractSqlDatabase database = sub.database;
    String alias = sub.recordTableAlias;
    Field<?> id = DSL.field(DSL.name(alias, database.recordIdField.getName()), database.uuidType());

    this.table = sub.initialize(DSL.table(DSL.name(database.recordTable.getName())).as(alias));
    this.on = join.valueField.eq(id);

    if (sub.needsDistinct) {
      parent.needsDistinct = true;
    }
  }
}

代码示例来源:origin: org.jooq/jooq

private static String getQualifiedName(Table<?> table) {
    StringBuilder sb = new StringBuilder();

    if (table.getSchema() != null) {
      sb.append(table.getSchema().getName());
      sb.append(".");
    }

    sb.append(table.getName());
    return sb.toString();
  }
}

代码示例来源:origin: my2iu/Jinq

public TableRowReader(Table<T> table)
{
 this.table = table;
 try {
   constructor = table.getRecordType().getDeclaredConstructor();
 } catch (Exception e) {
   throw new IllegalArgumentException("Cannot find constructor for class " + table.getRecordType().getName());
 }
}

代码示例来源:origin: org.jooq/jooq

@Override
public final void addJoinOnKey(TableLike<?> table, JoinType type) throws DataAccessException {
  // TODO: This and similar methods should be refactored, patterns extracted...
  int index = getFrom().size() - 1;
  Table<?> joined = null;
  switch (type) {
    case JOIN:
    case LEFT_OUTER_JOIN:
    case RIGHT_OUTER_JOIN:
    case FULL_OUTER_JOIN:
    case LEFT_SEMI_JOIN:
    case LEFT_ANTI_JOIN:
      joined = getFrom().get(index).join(table, type).onKey();
      break;
    default:
      throw new IllegalArgumentException("JoinType " + type + " is not supported with the addJoinOnKey() method. Use INNER or OUTER JOINs only");
  }
  getFrom().set(index, joined);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

RenamedTable(Table<R> delegate, String rename) {
    super(rename, delegate.getSchema());

    for (Field<?> field : delegate.fields()) {
      createField(field.getName(), field.getDataType(), this);
    }
  }
}

代码示例来源:origin: org.jooq/jooq

private final Name generatedName() {
  Name t = table.getQualifiedName();
  StringBuilder sb = new StringBuilder(table.getName());
  for (SortField<?> f : sortFields)
    sb.append('_').append(f.getName());
  sb.append("_idx");
  if (t.qualified())
    return t.qualifier().append(sb.toString());
  else
    return name(sb.toString());
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

@Override
public final void addJoinOnKey(TableLike<?> table, JoinType type, TableField<?, ?>... keyFields) throws DataAccessException {
  // TODO: This and similar methods should be refactored, patterns extracted...
  int index = getFrom().size() - 1;
  Table<?> joined = null;
  switch (type) {
    case JOIN:
      joined = getFrom().get(index).join(table).onKey(keyFields);
      break;
    case LEFT_OUTER_JOIN:
      joined = getFrom().get(index).leftOuterJoin(table).onKey(keyFields);
      break;
    case RIGHT_OUTER_JOIN:
      joined = getFrom().get(index).rightOuterJoin(table).onKey(keyFields);
      break;
    case FULL_OUTER_JOIN:
      joined = getFrom().get(index).fullOuterJoin(table).onKey(keyFields);
      break;
    default:
      throw new IllegalArgumentException("JoinType " + type + " is not supported with the addJoinOnKey() method. Use INNER or OUTER JOINs only");
  }
  getFrom().set(index, joined);
}

代码示例来源:origin: org.jooq/jooq

@SuppressWarnings("unchecked")
@Override
public final Class<? extends R> getRecordType() {
  // Generated record classes only come into play, when the select is
  // - on a single table
  // - a select *
  if (getFrom().size() == 1 && getSelect0().isEmpty()) {
    return (Class<? extends R>) getFrom().get(0).asTable().getRecordType();
  }
  else {
    return (Class<? extends R>) RecordImpl.class;
  }
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

joined = getFrom().get(index).join(table).on(conditions);
  break;
case LEFT_OUTER_JOIN: {
  TablePartitionByStep p = getFrom().get(index).leftOuterJoin(table);
  TableOnStep o = p;
  TablePartitionByStep p = getFrom().get(index).rightOuterJoin(table);
  TableOnStep o = p;
  joined = getFrom().get(index).fullOuterJoin(table).on(conditions);
  break;
  joined = getFrom().get(index).crossJoin(table);
  break;
case NATURAL_JOIN:
  joined = getFrom().get(index).naturalJoin(table);
  break;
case NATURAL_LEFT_OUTER_JOIN:
  joined = getFrom().get(index).naturalLeftOuterJoin(table);
  break;
case NATURAL_RIGHT_OUTER_JOIN:
  joined = getFrom().get(index).naturalRightOuterJoin(table);
  break;

代码示例来源:origin: rancher/cattle

if (foreignKey == null) {
  Table<?> childTable = JooqUtils.getTableFromRecordClass(child);
  for (ForeignKey<?, ?> foreignKeyTest : childTable.getReferences()) {
    if (foreignKeyTest.getKey().getTable().getRecordType() == parent) {
      if (propertyField != null) {
        if (foreignKeyTest.getFields().get(0).getName().equals(propertyField.getName())) {

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public final List<ForeignKey<Record, ?>> getReferences() {
  List<ForeignKey<?, ?>> result = new ArrayList<ForeignKey<?, ?>>();
  result.addAll(lhs.getReferences());
  result.addAll(rhs.getReferences());
  return (List) result;
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

@Override
public final Table<?> getTable(String name) {
  for (Table<?> table : getTables()) {
    if (table.getName().equals(name)) {
      return table;
    }
  }
  return null;
}

相关文章