Hello, 

This is my first post to this group. I am new to jooq and so far I am very 
impressed if not relieved to see how much life is better for anyone doing 
DB work with Java.

Currently, the values() method requires an argument sequence that matches 
the arguments of the columns() call that preceded it.

consider the following code:

public class StuffTable extends TableImpl<Record> {
    public final TableField<Record, Integer> ID = createField("id", 
SQLDataType.INTEGER.length(30));
    public final TableField<Record, String> STUFF_NAME = createField(
"stuff_name", SQLDataType.VARCHAR.length(100));
    public final TableField<Record, Integer> CREATOR = createField("creator"
, SQLDataType.VARCHAR.length(100)));
    public final TableField<Record, Integer> INSPIRATION = createField(
"inspiration", SQLDataType.VARCHAR.length(100)));


    public DonorFundsTable( ) {  super("donor_funds"); }


}
...


static STUFF_TABLE = new StuffTable();
...


Record record = dslContext.insertInto(STUFF_TABLE)
                .columns(STUFF_TABLE.STUFF_NAME, STUFF_TABLE.CREATOR, 
STUFF_TABLE.INSPIRATION)
                .values(name, creator,inspiration)
                .returning(DONOR_FUNDS_TABLE.ID)
                .fetchOne();
                

it is simple with 3 fields to keep the order of the columns and values in 
sync, less so and (much) more error prone if we had 10 or 20 fields.

How about adding a valuesFromMap(...)  or valuesFromPojo(...)
methods that given a Map object with values that map to the field names, or 
a POJO that would have getStuffName(), getCreator(), getInspiration() 
methods
so the values could be simply pulled out of the object ?


After all, this would mirror the  logic is in ResultQuery.fetchInto(Class<? 
extends E> type))..

Thoughts?

Cordially, 

 Erez Katz

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to