org.jooq.Table.getRecordType()方法的使用及代码示例

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

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

Table.getRecordType介绍

[英]The record type produced by this table.
[中]此表生成的记录类型。

代码示例

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

private void findMetamodelGetters(Schema schema)
{
 for (Table<?> table: schema.getTables())
 {
   String recordClassName = Type.getInternalName(table.getRecordType());
   for (Field<?> field: table.fields())
   {
    String name = field.getName();
    String getterName = "get" + name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase();
    MethodSignature methodSig = new MethodSignature(
       recordClassName,
       getterName,
       Type.getMethodDescriptor(Type.getType(field.getType())));
    fieldMethods.put(methodSig, field);
   }
 }
}

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

@Override
public final Class<? extends R> getRecordType() {
  return table.getRecordType();
}

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

@Override
public final Class<? extends R> getRecordType() {
  return table.getRecordType();
}

代码示例来源:origin: com.openle.module.lambda/lambda

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: rancher/cattle

protected Object newObject(TableMapping mapping) {
  Class<?> clz = mapping.originalTable.getRecordType();
  try {
    return clz.newInstance();
  } catch (InstantiationException e) {
    throw new IllegalStateException("Failed to construct [" + clz + "]", e);
  } catch (IllegalAccessException e) {
    throw new IllegalStateException("Failed to construct [" + clz + "]", e);
  }
}

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

@Override
  public Class<? extends R> getRecordType() {
    return alias.wrapped().getRecordType();
  }
}

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

@Override
  public Class<? extends R> getRecordType() {
    return alias.wrapped().getRecordType();
  }
}

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

@SuppressWarnings("unchecked")
TableDataType(Table<R> table) {
  super(SQLDialect.DEFAULT, (Class<R>) table.getRecordType(), getQualifiedName(table));
}

代码示例来源:origin: k55k32/cms-admin-end

private void initTable(Schema schema) {
  Class<?> is = findInterface(entityClass)
      .orElseThrow(() -> new RuntimeException("Entity class must implements one interface at least."));
  table = schema.getTables().stream().filter(t -> is.isAssignableFrom(t.getRecordType())).findFirst()
      .orElseThrow(() -> new RuntimeException("Can't find a table for the entity."));
}

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

protected void registerTableFields(Table<?> table) {
  Class<?> clz = table.getClass();
  for (java.lang.reflect.Field field : clz.getFields()) {
    if (TableField.class.isAssignableFrom(field.getType()) && Modifier.isPublic(field.getModifiers())) {
      try {
        field.setAccessible(true);
        TableField<?, ?> tableField = (TableField<?, ?>) field.get(table);
        String name = getNameFromField(table.getRecordType(), tableField.getName());
        tableFields.put(new FieldCacheKey(table.getRecordType(), name), tableField);
      } catch (IllegalArgumentException e) {
        throw new IllegalStateException(e);
      } catch (IllegalAccessException e) {
        throw new IllegalStateException(e);
      }
    }
  }
}

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

public List<Class<?>> getRecordTypes() {
  List<Class<?>> result = new ArrayList<Class<?>>();
  Schema schema = null;
  try {
    for (Field field : schemaClass.getFields()) {
      if (field.getType() == schemaClass) {
        schema = (Schema) field.get(schemaClass);
      }
    }
  } catch (IllegalAccessException e) {
    throw new IllegalArgumentException(e);
  }
  if (schema == null) {
    throw new IllegalArgumentException("Failed to find TABLE field on [" + schemaClass + "]");
  }
  for (Table<?> table : schema.getTables()) {
    result.add(table.getRecordType());
  }
  return result;
}

代码示例来源:origin: com.openle.module.lambda/lambda

@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: org.jooq/jooq

/**
 * Create a new record
 */
@SuppressWarnings("unchecked")
static final <R extends Record> RecordDelegate<R> newRecord(boolean fetched, Table<R> type, Configuration configuration) {
  return (RecordDelegate<R>) newRecord(fetched, type.getRecordType(), type.fields(), configuration);
}

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

/**
 * Create a new record
 */
@SuppressWarnings("unchecked")
static final <R extends Record> RecordDelegate<R> newRecord(Table<R> type, Configuration configuration) {
  return (RecordDelegate<R>) newRecord(type.getRecordType(), type.fields(), configuration);
}

代码示例来源: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.openle.module.lambda/lambda

private void findMetamodelGetters(Schema schema)
{
 for (Table<?> table: schema.getTables())
 {
   String recordClassName = Type.getInternalName(table.getRecordType());
   for (Field<?> field: table.fields())
   {
    String name = field.getName();
    String getterName = "get" + name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase();
    MethodSignature methodSig = new MethodSignature(
       recordClassName,
       getterName,
       Type.getMethodDescriptor(Type.getType(field.getType())));
    fieldMethods.put(methodSig, field);
   }
 }
}

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

@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;
  }
}

相关文章