Reputation: 2692
Table<Record> myTable = DSL.table("myTable");
Table<Record> a = myTable.as("a");
Field<Integer> myField = DSL.field("myField", SQLDataType.INTEGER);
a.field("myField"); // == null
a.field("myField", SQLDataType.INTEGER); // == null
a.field(myField); // == null
I want to use a table expression in a comparison, similar to this. I am using jOOQ just to generate SQL strings; I am not using its code generation for my table types.
Upvotes: 0
Views: 43
Reputation: 2692
I just now saw this comment in the documentation:
A better solution would be any of these:
Field MY_FIELD1 = field(MY_TABLE.getName() + ".MY_FIELD"); Field MY_FIELD2 = field(name(MY_TABLE.getName(), "MY_FIELD"));
I think that this section of the manual might be quite helpful for you: http://www.jooq.org/doc/latest/manual/sql-building/names
This worked for me, but I needed to make some changes because I'm using type-safe fields. I wrote this helper:
private <T> Field<T> field(final Table<Record> table, final Field<T> field) {
return DSL.field(DSL.name(table.getName(), field.getName()), field.getDataType());
}
Upvotes: 1