// record is always nullRecord record = create.insertInto(tableByName("MY_TABLE"), fieldByName("FIELD1"), fieldByName("FIELD2")).values(values).returning(fieldByName("ID_FIELD")).fetchOne();
class TemporaryTable extends TableImpl {private final String idColumn;TemporaryTable(final String name,final String idColumn) {super(name);this.idColumn = idColumn;}@Overridepublic Identity getIdentity() {return new Identity() {@Overridepublic Table getTable() {return TemporaryTable.this;}@Overridepublic TableField getField() {// What to return here?!}};}public <T> void addField(final String name, final DataType<T> dataType) {createField(name, dataType, this);}}
How about TemporaryTable.this.field("ID")?
How about TemporaryTable.this.field("ID")?
> Good question. TableField might've been a mistake when it was first
> introduced in jOOQ 1.x. The reason is the simple fact that it is very
> hard to enforce throughout the API without making those people angry
> that do not use the code generator. This can be seen easily by the
> fact that the type is hardly ever used in the jOOQ API:
> http://www.jooq.org/javadoc/latest/org/jooq/class-use/TableField.html
>
> I will check again, why I hadn't considered removing it in jOOQ 3.0...
Changing it to Field would also fix the comparison issue I think because then a Field would be compared to a Field.
Since this is a major release you could argue that API changes are allowed.
Unfortunately, TableField is used in a couple of places, specifically
the ON KEY join method. I didn't have time to try to resolve that
dependency, but I think it would be possible to pull up the getTable()
method to Field.table() and make it "optional", i.e. allow for it to
return null, if a field's table is unknown or not available.
Hi Lukas,Unfortunately, TableField is used in a couple of places, specifically
the ON KEY join method. I didn't have time to try to resolve that
dependency, but I think it would be possible to pull up the getTable()
method to Field.table() and make it "optional", i.e. allow for it to
return null, if a field's table is unknown or not available.
if you could do that, that would be great! If you have a better idea of how to fix the initial problem, that's fine with me too ;)
But at the moment I'm using traditional JDBC for an INSERT statement because I need to fetch the generated ID. All other code is jOOQ already. Would really like to completely use jOOQ here.
ThanksSven
--