本文整理了Java中org.jooq.TableField.getName()
方法的一些代码示例,展示了TableField.getName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TableField.getName()
方法的具体详情如下:
包路径:org.jooq.TableField
类名称:TableField
方法名:getName
暂无
代码示例来源:origin: shilad/wikibrain
private static String[] getFieldNames(TableField[] fields) {
String names[] = new String[fields.length];
for (int i = 0; i < fields.length; i++) {
names[i] = fields[i].getName();
}
return names;
}
代码示例来源:origin: rancher/cattle
@Override
public String convertToPropertyNameString(Class<?> recordClass, Object key) {
if (key instanceof String) {
return (String) key;
}
if (key instanceof TableField) {
TableField<?, ?> field = (TableField<?, ?>) key;
return getNameFromField(recordClass, field.getName());
}
return key == null ? null : key.toString();
}
代码示例来源:origin: mevdschee/java-crud-api
private String findForeignKeyFieldName(ForeignKey<?, ?> fk) {
TableField<?, ?>[] pks = fk.getFieldsArray();
if (pks.length == 1) {
return pks[0].getName();
}
return null;
}
代码示例来源:origin: rancher/cattle
protected String getResourceNameField(Client client) {
return getResourceField(client).getName().toLowerCase();
}
代码示例来源:origin: cn.vertxup/vertx-up
private <T> T skipPrimaryKey(final T entity) {
final Table<?> tableField = Ut.field(this.vertxDAO, "table");
final UniqueKey key = tableField.getPrimaryKey();
key.getFields().stream().map(item -> ((TableField) item).getName())
.filter(this.revert::containsKey)
.map(this.revert::get)
.forEach(item -> Ut.field(entity, item.toString(), null));
return entity;
}
代码示例来源:origin: silentbalanceyh/vertx-zero
private <T> T skipPrimaryKey(final T entity) {
final Table<?> tableField = Ut.field(this.vertxDAO, "table");
final UniqueKey key = tableField.getPrimaryKey();
key.getFields().stream().map(item -> ((TableField) item).getName())
.filter(this.revert::containsKey)
.map(this.revert::get)
.forEach(item -> Ut.field(entity, item.toString(), null));
return 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
if (foreignKeyTest.getKey().getTable().getRecordType() == parent) {
if (propertyField != null) {
if (foreignKeyTest.getFields().get(0).getName().equals(propertyField.getName())) {
if (foreignKey != null) {
throw new IllegalStateException("Found more that one foreign key from [" + child + "] to [" + parent + "]");
代码示例来源: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 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: com.walmartlabs.concord.server/concord-server
INVENTORIES.INVENTORY_ID.getName(),
INVENTORIES.INVENTORY_NAME.getName(),
INVENTORIES.PARENT_INVENTORY_ID.getName(),
INVENTORIES.ORG_ID.getName(),
ORGANIZATIONS.ORG_NAME.getName(),
INVENTORIES.VISIBILITY.getName(),
INVENTORIES.OWNER_ID.getName(),
USERS.USERNAME.getName())
.as(s1.unionAll(s2))
.select().from(nodes)
代码示例来源:origin: jklingsporn/vertx-jooq
@Override
@SuppressWarnings("unchecked")
protected Function<Object,T> keyConverter(){
return o -> {
io.reactiverse.pgclient.Row row = (io.reactiverse.pgclient.Row) o;
TableField<R, ?>[] fields = getTable().getPrimaryKey().getFieldsArray();
if(fields.length == 1){
return (T)row.getValue(fields[0].getName());
}
Object[] values = new Object[row.size()];
for(int i=0;i<row.size();i++){
values[i] = row.getValue(i);
}
return compositeKeyRecord(values);
};
}
代码示例来源:origin: com.torodb.torod.backends/common
private void createIndexTableIfNotExists(DSLContext dsl) {
boolean tableExists = dsl.select(DSL.count())
.from("information_schema.tables")
.where(
DSL.field("table_schema").eq(colSchema.getName())
.and(DSL.field("table_name").eq(toroIndexTable.getName()))
)
.fetchOne(0, int.class) > 0;
if (!tableExists) {
Name tableName = DSL.name(colSchema.getName(), toroIndexTable.getName());
dsl.execute(
databaseInterface.createIndexesTableStatement(
dsl.render(tableName), toroIndexTable.nameColumn.getName(),
toroIndexTable.indexColumn.getName()
)
);
}
}
代码示例来源: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());
}
代码示例来源: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.walmartlabs.concord.server/concord-server
private List<InventoryDataItem> get(DSLContext tx, UUID inventoryId, String path) {
Table<Record> nodes = table("nodes");
Inventories i1 = INVENTORIES.as("i1");
Inventories i2 = INVENTORIES.as("i2");
SelectConditionStep<Record3<UUID, UUID, Integer>> s1 =
select(i1.INVENTORY_ID, i1.PARENT_INVENTORY_ID, value(1))
.from(i1)
.where(i1.INVENTORY_ID.eq(inventoryId));
SelectConditionStep<Record3<UUID, UUID, Integer>> s2 =
select(i2.INVENTORY_ID, i2.PARENT_INVENTORY_ID, level().add(1))
.from(i2, nodes)
.where(i2.INVENTORY_ID.eq(INVENTORIES.as("nodes").PARENT_INVENTORY_ID));
SelectConditionStep<Record3<String, String, Integer>> s = tx.withRecursive("nodes", INVENTORIES.INVENTORY_ID.getName(), INVENTORIES.PARENT_INVENTORY_ID.getName(), "level")
.as(s1.unionAll(s2))
.select(INVENTORY_DATA.ITEM_PATH, INVENTORY_DATA.ITEM_DATA.cast(String.class), level())
.from(INVENTORY_DATA, nodes)
.where(INVENTORY_DATA.INVENTORY_ID.eq(INVENTORIES.as("nodes").INVENTORY_ID)
.and(INVENTORY_DATA.ITEM_PATH.startsWith(path)));
return s.fetch(this::toEntry);
}
代码示例来源:origin: com.walmartlabs.concord.server/concord-server
String rangeExpr = PROCESS_LOGS.CHUNK_RANGE.getName() + " && int4range(?, ?)";
return tx.select(field(lowerBoundExpr), PROCESS_LOGS.CHUNK_DATA)
.from(PROCESS_LOGS)
String rangeExpr = PROCESS_LOGS.CHUNK_RANGE.getName() + " && (select range from x)";
return tx.with("x").as(select(processLogLastNBytes2(instanceId, createdAt, end).as("range")))
.select(field(lowerBoundExpr), PROCESS_LOGS.CHUNK_DATA)
代码示例来源:origin: org.jooq/jooq-meta
@Override
protected void loadCheckConstraints(DefaultRelations relations) throws SQLException {
TableConstraints tc = TABLE_CONSTRAINTS.as("tc");
CheckConstraints cc = CHECK_CONSTRAINTS.as("cc");
// [#2808] [#3019] Workaround for bad handling of JOIN .. USING
Field<String> constraintName = field(name(cc.CONSTRAINT_NAME.getName()), String.class);
for (Record record : create()
.select(
tc.TABLE_SCHEMA,
tc.TABLE_NAME,
constraintName,
cc.CHECK_CLAUSE
)
.from(tc)
.join(cc)
.using(tc.CONSTRAINT_CATALOG, tc.CONSTRAINT_SCHEMA, tc.CONSTRAINT_NAME)
.where(tc.TABLE_SCHEMA.in(getInputSchemata()))
.fetch()) {
SchemaDefinition schema = getSchema(record.get(tc.TABLE_SCHEMA));
TableDefinition table = getTable(schema, record.get(tc.TABLE_NAME));
if (table != null) {
relations.addCheckConstraint(table, new DefaultCheckConstraintDefinition(
schema,
table,
record.get(constraintName),
record.get(cc.CHECK_CLAUSE)
));
}
}
}
内容来源于网络,如有侵权,请联系作者删除!