org.jooq.TableField.getTable()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(11.1k)|赞(0)|评价(0)|浏览(106)

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

TableField.getTable介绍

暂无

代码示例

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

private final String tableName(Field<?> field) {
  if (field instanceof TableField) {
    Table<?> table = ((TableField<?, ?>) field).getTable();
    if (table != null) {
      return table.getName();
    }
  }
  return null;
}

代码示例来源:origin: shilad/wikibrain

public FastLoader(WpDataSource ds, TableField[] fields) throws DaoException {
  this(ds, fields[0].getTable().getName(), getFieldNames(fields));
}

代码示例来源:origin: shilad/wikibrain

@Override
public void endLoad() throws  DaoException {
  if (loader != null) {
    loader.endLoad();
  }
  LOG.info("creating indexes in {}-create-indexes.sql (this can take some time)", sqlScriptPrefix);
  executeSqlScriptWithSuffix("-create-indexes.sql");
  if (fields != null && fields.length > 0) {
    wpDs.optimize(fields[0].getTable());
  }
}

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

@Override
public final JoinTable onKey(TableField<?, ?>... keyFields) throws DataAccessException {
  if (keyFields != null && keyFields.length > 0) {
    if (keyFields[0].getTable().equals(lhs)) {
      for (ForeignKey<?, ?> key : lhs.getReferences()) {
        if (key.getFields().containsAll(asList(keyFields))) {
          return onKey(key);
        }
      }
    }
    else if (keyFields[0].getTable().equals(rhs)) {
      for (ForeignKey<?, ?> key : rhs.getReferences()) {
        if (key.getFields().containsAll(asList(keyFields))) {
          return onKey(key);
        }
      }
    }
  }
  throw onKeyException();
}

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

@Override
public <T> T fetchValue(TableField<?, T> field) {
  return fetchValue(select(field).from(field.getTable()));
}

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

@Override
public String getTableName(int column) throws SQLException {
  rs.checkNotClosed();
  Field<?> field = rs.result.field(column - 1);
  if (field instanceof TableField) {
    Table<?> table = ((TableField<?, ?>) field).getTable();
    if (table != null) {
      return table.getName();
    }
  }
  // By default, no table is available
  return "";
}

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

@Override
public String getTableName(int column) throws SQLException {
  rs.checkNotClosed();
  Field<?> field = rs.result.field(column - 1);
  if (field instanceof TableField) {
    Table<?> table = ((TableField<?, ?>) field).getTable();
    if (table != null) {
      return table.getName();
    }
  }
  // By default, no table is available
  return "";
}

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

@Override
public <T> List<T> fetchValues(TableField<?, T> field) {
  return fetchValues(select(field).from(field.getTable()));
}

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

@Override
public final JoinTable onKey(TableField<?, ?>... keyFields) throws DataAccessException {
  if (keyFields != null && keyFields.length > 0) {
    if (search(lhs, keyFields[0].getTable()) != null) {
      for (ForeignKey<?, ?> key : lhs.getReferences()) {
        if (key.getFields().containsAll(asList(keyFields))) {
          return onKey(key);
        }
      }
    }
    else if (search(rhs, keyFields[0].getTable()) != null) {
      for (ForeignKey<?, ?> key : rhs.getReferences()) {
        if (key.getFields().containsAll(asList(keyFields))) {
          return onKey(key);
        }
      }
    }
  }
  throw onKeyException(OnKeyExceptionReason.NOT_FOUND, null, null);
}

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

Table<?> table = ((TableField<?, ?>) field).getTable();

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

Table<?> table = ((TableField<?, ?>) field).getTable();

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

Table<?> table = ((TableField<?, ?>) field).getTable();

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

@Override
  public boolean equals(Object that) {
    if (this == that) {
      return true;
    }

    // [#2144] TableFieldImpl equality can be decided without executing the
    // rather expensive implementation of AbstractQueryPart.equals()
    if (that instanceof TableField) {
      TableField<?, ?> other = (TableField<?, ?>) that;
      return
        StringUtils.equals(getTable(), other.getTable()) &&
        StringUtils.equals(getName(), other.getName());
    }

    return super.equals(that);
  }
}

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

@Override
  public boolean equals(Object that) {
    if (this == that) {
      return true;
    }

    // [#2144] TableFieldImpl equality can be decided without executing the
    // rather expensive implementation of AbstractQueryPart.equals()
    if (that instanceof TableField) {
      TableField<?, ?> other = (TableField<?, ?>) that;
      return
        StringUtils.equals(getTable(), other.getTable()) &&
        StringUtils.equals(getName(), other.getName());
    }

    return super.equals(that);
  }
}

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

protected void register(ForeignKey<?, ?> foreignKey) {
  TableField<?, ?>[] fields = foreignKey.getFieldsArray();
  if (fields.length == 0 || fields.length > 1) {
    return;
  }
  TableField<?, ?> field = fields[0];
  if (!field.getDataType().isNumeric()) {
    return;
  }
  String propertyName = getNameFromField(field.getTable().getRecordType(), field.getName());
  String referenceName = propertyName;
  if (field.getName().endsWith(ID_FIELD)) {
    referenceName = referenceName.substring(0, referenceName.length() - 2);
  }
  Class<?> localType = foreignKey.getTable().getRecordType();
  Class<?> foreignType = foreignKey.getKey().getTable().getRecordType();
  Schema localSchema = schemaFactory.getSchema(localType);
  String childName = localSchema.getPluralName();
  String childNameOverride = ArchaiusUtil.getString(
      String.format("object.link.name.%s.%s.override", localType.getSimpleName(), propertyName).toLowerCase()).get();
  if (childNameOverride != null) {
    childName = childNameOverride;
  }
  register(localType, new ForeignKeyRelationship(REFERENCE, referenceName, propertyName, foreignType, foreignKey));
  register(foreignType, new ForeignKeyRelationship(CHILD, childName, propertyName, localType, foreignKey));
}

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

@Override
public String getSchemaName(int column) throws SQLException {
  rs.checkNotClosed();
  Field<?> field = rs.result.field(column - 1);
  if (field instanceof TableField) {
    Table<?> table = ((TableField<?, ?>) field).getTable();
    if (table != null) {
      Schema schema = table.getSchema();
      if (schema != null) {
        Configuration configuration = rs.result.configuration();
        Schema mapped = null;
        if (configuration != null)
          mapped = DSL.using(configuration).map(schema);
        if (mapped != null)
          return mapped.getName();
        else
          return schema.getName();
      }
    }
  }
  // By default, no schema is available
  return "";
}

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

protected void addJoin(SelectQuery<?> query, Table<?> toTable, SchemaFactory schemaFactory, String fromType, Table<?> from, String asName,
               Relationship rel) {
  TableField<?, Object> fieldFrom = null;
  TableField<?, Object> fieldTo = null;
  switch (rel.getRelationshipType()) {
  case REFERENCE:
    fieldFrom = JooqUtils.getTableField(getMetaDataManager(), fromType, rel.getPropertyName());
    fieldTo = JooqUtils.getTableField(getMetaDataManager(), schemaFactory.getSchemaName(rel.getObjectType()), ObjectMetaDataManager.ID_FIELD);
    break;
  case CHILD:
    fieldFrom = JooqUtils.getTableField(getMetaDataManager(), fromType, ObjectMetaDataManager.ID_FIELD);
    fieldTo = JooqUtils.getTableField(getMetaDataManager(), schemaFactory.getSchemaName(rel.getObjectType()), rel.getPropertyName());
    break;
  default:
    throw new IllegalArgumentException("Illegal Relationship type [" + rel.getRelationshipType() + "]");
  }
  if (fieldFrom == null || fieldTo == null) {
    throw new IllegalStateException("Failed to construction join query for [" + fromType + "] [" + from + "] [" + rel + "]");
  }
  query.addJoin(toTable, JoinType.LEFT_OUTER_JOIN, fieldFrom.eq(fieldTo.getTable().as(asName).field(fieldTo.getName())));
  query.addOrderBy(fieldTo.getTable().as(asName).field(ObjectMetaDataManager.ID_FIELD).asc());
}

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

@Override
public String getSchemaName(int column) throws SQLException {
  rs.checkNotClosed();
  Field<?> field = rs.result.field(column - 1);
  if (field instanceof TableField) {
    Table<?> table = ((TableField<?, ?>) field).getTable();
    if (table != null) {
      Schema schema = table.getSchema();
      if (schema != null) {
        Configuration configuration = ((AttachableInternal) rs.result).configuration();
        Schema mapped = null;
        if (configuration != null) {
          mapped = DSL.using(configuration).map(schema);
        }
        if (mapped != null) {
          return mapped.getName();
        }
        else {
          return schema.getName();
        }
      }
    }
  }
  // By default, no schema is available
  return "";
}

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

@Override
protected Object getMapLink(String fromType, String id, MapRelationship rel, ApiRequest request) {
  SchemaFactory schemaFactory = request.getSchemaFactory();
  /*
   * We don't required the mapping type to be visible external, that's why
   * we use the schemaFactory from the objectManager, because it is the
   * superset schemaFactory.
   */
  String mappingType = getObjectManager().getSchemaFactory().getSchemaName(rel.getMappingType());
  String type = schemaFactory.getSchemaName(rel.getObjectType());
  Map<Table<?>, Condition> joins = new LinkedHashMap<Table<?>, Condition>();
  Map<Object, Object> criteria = new LinkedHashMap<Object, Object>();
  if (mappingType == null || type == null) {
    return null;
  }
  Table<?> mappingTable = JooqUtils.getTable(schemaFactory, rel.getMappingType());
  TableField<?, Object> fieldFrom = JooqUtils.getTableField(getMetaDataManager(), type, ObjectMetaDataManager.ID_FIELD);
  TableField<?, Object> fieldTo = JooqUtils.getTableField(getMetaDataManager(), mappingType, rel.getOtherRelationship().getPropertyName());
  TableField<?, Object> fieldRemoved = JooqUtils.getTableField(getMetaDataManager(), mappingType, ObjectMetaDataManager.REMOVED_FIELD);
  TableField<?, Object> fromTypeIdField = JooqUtils.getTableField(getMetaDataManager(), mappingType, rel.getSelfRelationship().getPropertyName());
  org.jooq.Condition cond = fieldFrom.eq(fieldTo.getTable().field(fieldTo.getName())).and(
      fieldRemoved == null ? DSL.trueCondition() : fieldRemoved.isNull());
  joins.put(mappingTable, cond);
  criteria.put(Condition.class, fromTypeIdField.eq(id));
  return listInternal(schemaFactory, type, criteria, new ListOptions(request), joins);
}

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

protected void addMappingJoins(SelectQuery<?> query, Table<?> toTable, SchemaFactory schemaFactory, String fromType, Table<?> from, String asName,
    MapRelationship rel) {
  Table<?> mappingTable = JooqUtils.getTableFromRecordClass(rel.getMappingType());
  /*
   * We don't required the mapping type to be visible external, that's why
   * we use the schemaFactory from the objectManager, because it is the
   * superset schemaFactory.
   */
  String mappingType = getObjectManager().getSchemaFactory().getSchemaName(rel.getMappingType());
  TableField<?, Object> fieldFrom = JooqUtils.getTableField(getMetaDataManager(), fromType, ObjectMetaDataManager.ID_FIELD);
  TableField<?, Object> fieldTo = JooqUtils.getTableField(getMetaDataManager(), mappingType, rel.getPropertyName());
  TableField<?, Object> fieldRemoved = JooqUtils.getTableField(getMetaDataManager(), mappingType, ObjectMetaDataManager.REMOVED_FIELD);
  org.jooq.Condition cond = fieldFrom.eq(fieldTo.getTable().field(fieldTo.getName())).and(
      fieldRemoved == null ? DSL.trueCondition() : fieldRemoved.isNull());
  query.addJoin(mappingTable, JoinType.LEFT_OUTER_JOIN, cond);
  fieldFrom = JooqUtils.getTableField(getMetaDataManager(), mappingType, rel.getOtherRelationship().getPropertyName());
  fieldTo = JooqUtils.getTableField(getMetaDataManager(), schemaFactory.getSchemaName(rel.getObjectType()), ObjectMetaDataManager.ID_FIELD);
  cond = fieldFrom.eq(fieldTo.getTable().asTable(asName).field(fieldTo.getName()));
  query.addJoin(toTable, JoinType.LEFT_OUTER_JOIN, cond);
  query.addOrderBy(fieldTo.getTable().asTable(asName).field(fieldTo.getName()).asc());
}

相关文章