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

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

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

TableField.getDataType介绍

暂无

代码示例

代码示例来源:origin: jklingsporn/vertx-jooq

@SuppressWarnings("unchecked")
protected Condition equalKeys(Collection<T> ids){
  UniqueKey<?> uk = getTable().getPrimaryKey();
  Objects.requireNonNull(uk,()->"No primary key");
  /**
   * Copied from jOOQs DAOImpl#equal-method
   */
  TableField<? extends Record, ?>[] pk = uk.getFieldsArray();
  Condition condition;
  if (pk.length == 1) {
    if (ids.size() == 1) {
      condition = equalKey(ids.iterator().next());
    }else {
      condition = pk[0].in(pk[0].getDataType().convert(ids));
    }
  }else {
    condition = row(pk).in(ids.toArray(new Record[ids.size()]));
  }
  return condition;
}

代码示例来源:origin: io.github.jklingsporn/vertx-jooq-shared

@SuppressWarnings("unchecked")
protected Condition equalKeys(Collection<T> ids){
  UniqueKey<?> uk = getTable().getPrimaryKey();
  Objects.requireNonNull(uk,()->"No primary key");
  /**
   * Copied from jOOQs DAOImpl#equal-method
   */
  TableField<? extends Record, ?>[] pk = uk.getFieldsArray();
  Condition condition;
  if (pk.length == 1) {
    if (ids.size() == 1) {
      condition = equalKey(ids.iterator().next());
    }else {
      condition = pk[0].in(pk[0].getDataType().convert(ids));
    }
  }else {
    condition = row(pk).in(ids.toArray(new Record[ids.size()]));
  }
  return condition;
}

代码示例来源:origin: jklingsporn/vertx-jooq-async

@SuppressWarnings("unchecked")
public static <R extends UpdatableRecord<R>,T,F> F applyConditionally(T id, Table<R> table, Function<Condition, F> function){
  UniqueKey<?> uk = table.getPrimaryKey();
  Objects.requireNonNull(uk,()->"No primary key");
  /**
   * Copied from jOOQs DAOImpl#equal-method
   */
  TableField<? extends Record, ?>[] pk = uk.getFieldsArray();
  Condition condition;
  if (pk.length == 1) {
    condition = ((Field<Object>) pk[0]).equal(pk[0].getDataType().convert(id));
  }
  else {
    condition = row(pk).equal((Record) id);
  }
  return function.apply(condition);
}

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

/**
 * Set a generated version and timestamp value onto this record after
 * successfully storing the record.
 */
final void setRecordVersionAndTimestamp(BigInteger version, Timestamp timestamp) {
  if (version != null) {
    TableField<R, ?> field = getTable().getRecordVersion();
    int fieldIndex = indexOrFail(fieldsRow(), field);
    Object value = field.getDataType().convert(version);
    values[fieldIndex] = value;
    originals[fieldIndex] = value;
    changed.clear(fieldIndex);
  }
  if (timestamp != null) {
    TableField<R, ?> field = getTable().getRecordTimestamp();
    int fieldIndex = indexOrFail(fieldsRow(), field);
    Object value = field.getDataType().convert(timestamp);
    values[fieldIndex] = value;
    originals[fieldIndex] = value;
    changed.clear(fieldIndex);
  }
}

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

/**
   * Set a generated version and timestamp value onto this record after
   * successfully storing the record.
   */
  private final void setRecordVersionAndTimestamp(BigInteger version, Timestamp timestamp) {
    if (version != null) {
      TableField<R, ?> field = getTable().getRecordVersion();
      setValue(field, new Value<Object>(field.getDataType().convert(version)));
    }
    if (timestamp != null) {
      TableField<R, ?> field = getTable().getRecordTimestamp();
      setValue(field, new Value<Object>(field.getDataType().convert(timestamp)));
    }
  }
}

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

@SuppressWarnings("unchecked")
protected /* non-final */ T compositeKeyRecord(Object... values) {
  UniqueKey<R> key = table.getPrimaryKey();
  if (key == null)
    return null;
  TableField<R, Object>[] fields = (TableField<R, Object>[]) key.getFieldsArray();
  Record result = DSL.using(configuration)
            .newRecord(fields);
  for (int i = 0; i < values.length; i++)
    result.set(fields[i], fields[i].getDataType().convert(values[i]));
  return (T) result;
}

代码示例来源:origin: io.github.jklingsporn/vertx-jooq-shared

@SuppressWarnings("unchecked")
protected Condition equalKey(T id){
  UniqueKey<?> uk = getTable().getPrimaryKey();
  Objects.requireNonNull(uk,()->"No primary key");
  /**
   * Copied from jOOQs DAOImpl#equal-method
   */
  TableField<? extends Record, ?>[] pk = uk.getFieldsArray();
  Condition condition;
  if (pk.length == 1) {
    condition = ((Field<Object>) pk[0]).equal(pk[0].getDataType().convert(id));
  }
  else {
    condition = row(pk).equal((Record) id);
  }
  return condition;
}

代码示例来源:origin: jklingsporn/vertx-jooq

@SuppressWarnings("unchecked")
protected Condition equalKey(T id){
  UniqueKey<?> uk = getTable().getPrimaryKey();
  Objects.requireNonNull(uk,()->"No primary key");
  /**
   * Copied from jOOQs DAOImpl#equal-method
   */
  TableField<? extends Record, ?>[] pk = uk.getFieldsArray();
  Condition condition;
  if (pk.length == 1) {
    condition = ((Field<Object>) pk[0]).equal(pk[0].getDataType().convert(id));
  }
  else {
    condition = row(pk).equal((Record) id);
  }
  return condition;
}

代码示例来源:origin: jklingsporn/vertx-jooq

@SuppressWarnings("unchecked")
protected /* non-final */ T compositeKeyRecord(Object... values) {
  UniqueKey<R> key = table.getPrimaryKey();
  if (key == null)
    return null;
  TableField<R, Object>[] fields = (TableField<R, Object>[]) key.getFieldsArray();
  Record result = DSL.using(queryExecutor.configuration())
      .newRecord(fields);
  for (int i = 0; i < values.length; i++)
    result.set(fields[i], fields[i].getDataType().convert(values[i]));
  return (T) result;
}

代码示例来源:origin: io.github.jklingsporn/vertx-jooq-shared

@SuppressWarnings("unchecked")
protected /* non-final */ T compositeKeyRecord(Object... values) {
  UniqueKey<R> key = table.getPrimaryKey();
  if (key == null)
    return null;
  TableField<R, Object>[] fields = (TableField<R, Object>[]) key.getFieldsArray();
  Record result = DSL.using(queryExecutor.configuration())
      .newRecord(fields);
  for (int i = 0; i < values.length; i++)
    result.set(fields[i], fields[i].getDataType().convert(values[i]));
  return (T) result;
}

代码示例来源: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: rancher/cattle

@SuppressWarnings("unchecked")
public static <T extends UpdatableRecord<?>> T findById(DSLContext context, Class<T> clz, Object id) {
  if (id == null)
    return null;
  Table<?> table = getTableFromRecordClass(clz);
  if (table == null)
    return null;
  UniqueKey<?> key = table.getPrimaryKey();
  if (key == null || key.getFieldsArray().length != 1)
    return null;
  TableField<?, Object> keyField = (TableField<?, Object>) key.getFieldsArray()[0];
  /* Convert object because we are abusing type safety here */
  Object converted = keyField.getDataType().convert(id);
  return (T) context.selectFrom(table).where(keyField.eq(converted)).fetchOne();
}

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

private final int store0(Field<?>[] storeFields) {
  TableField<R, ?>[] keys = getPrimaryKey().getFieldsArray();
  boolean executeUpdate = false;
  // [#2764] If primary key values are allowed to be changed,
  // inserting is only possible without prior loading of pk values
  if (updatablePrimaryKeys(settings(this))) {
    executeUpdate = fetched;
  }
  else {
    for (TableField<R, ?> field : keys) {
      // If any primary key value is null or changed
      if (changed(field) ||
      // [#3237] or if a NOT NULL primary key value is null, then execute an INSERT
        (field.getDataType().nullable() == false && get(field) == null)) {
        executeUpdate = false;
        break;
      }
      // Otherwise, updates are possible
      executeUpdate = true;
    }
  }
  int result = 0;
  if (executeUpdate) {
    result = storeUpdate(storeFields, keys);
  }
  else {
    result = storeInsert(storeFields);
  }
  return result;
}

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

field("({0})::information_schema.sql_identifier", col.COLUMN_NAME.getDataType(), a.ATTNAME).as(col.COLUMN_NAME),
field("({0})::information_schema.cardinal_number", col.ORDINAL_POSITION.getDataType(), a.ATTNUM).as(col.ORDINAL_POSITION),
field("({0})::information_schema.character_data", col.DATA_TYPE.getDataType(),
  when(t.TYPTYPE.eq(inline("d")),
    when(bt.TYPELEM.ne(inline(0L)).and(bt.TYPLEN.eq(inline((short) -1))), inline("ARRAY"))
    .when(nt.NSPNAME.eq(inline("pg_catalog")), field("format_type({0}, NULL::integer)", String.class, a.ATTTYPID))
    .otherwise(inline("USER-DEFINED")))).as(col.DATA_TYPE),
field("(information_schema._pg_char_max_length(information_schema._pg_truetypid(a.*, t.*), information_schema._pg_truetypmod(a.*, t.*)))::information_schema.cardinal_number", col.CHARACTER_MAXIMUM_LENGTH.getDataType()).as(col.CHARACTER_MAXIMUM_LENGTH),
field("(information_schema._pg_numeric_precision(information_schema._pg_truetypid(a.*, t.*), information_schema._pg_truetypmod(a.*, t.*)))::information_schema.cardinal_number", col.NUMERIC_PRECISION.getDataType()).as(col.NUMERIC_PRECISION),
field("(information_schema._pg_numeric_scale(information_schema._pg_truetypid(a.*, t.*), information_schema._pg_truetypmod(a.*, t.*)))::information_schema.cardinal_number", col.NUMERIC_SCALE.getDataType()).as(col.NUMERIC_SCALE),
field("({0})::information_schema.yes_or_no", col.IS_NULLABLE.getDataType(),
  when(condition(a.ATTNOTNULL).or(t.TYPTYPE.eq(inline("d")).and(t.TYPNOTNULL)), inline("NO"))
  .otherwise(inline("YES"))).as(col.IS_NULLABLE),
field("(pg_get_expr({0}, {1}))::information_schema.character_data", col.COLUMN_DEFAULT.getDataType(), ad.ADBIN, ad.ADRELID).as(col.COLUMN_DEFAULT),
field("({0})::information_schema.sql_identifier", col.UDT_SCHEMA.getDataType(),
  nvl(nbt.NSPNAME, nt.NSPNAME)).as(col.UDT_SCHEMA),
field("({0})::information_schema.sql_identifier", col.UDT_NAME.getDataType(),
  nvl(bt.TYPNAME, t.TYPNAME)).as(col.UDT_NAME),
PG_DESCRIPTION.DESCRIPTION)

相关文章