Hello,

Good question - perhaps that isn't really clear from the documentation. The
idea is that you provide a Class reference of a class that can be
constructed when records are created for that table, e.g. using
DSLContext.selectFrom(myCustomTable). Ideally, you will be creating a Table
/ Record pair like so:

public class BookTable extends CustomTable<BookRecord> {

    public static final BookTable                      BOOK       = new
BookTable();

    public static final TableField<BookRecord, String> FIRST_NAME =
createField("FIRST_NAME", SQLDataType.VARCHAR, BOOK);
    public static final TableField<BookRecord, String> LAST_NAME  =
createField("LAST_NAME", SQLDataType.VARCHAR, BOOK);
    public static final TableField<BookRecord, Short>  ID         =
createField("ID", SQLDataType.SMALLINT, BOOK);
    public static final TableField<BookRecord, String> TITLE      =
createField("TITLE", SQLDataType.VARCHAR, BOOK);

    protected BookTable() {
        super(null);
    }

    @Override
    public Class<? extends BookRecord> getRecordType() {
        return BookRecord.class;
    }
}

public class BookRecord extends CustomRecord<BookRecord> {

    protected BookRecord() {
        super(BookTable.BOOK);
    }

    // Optional getters / setters
}


The important thing will be to provide a class with a default constructor.
I hope this helps, so far.

Perhaps, if you illustrate your use-case, I will be able to help you a bit
more.

Cheers,
Lukas


2015-08-11 2:39 GMT+02:00 <[email protected]>:

> I am trying to create a CustomTable so that aliases using .field() work
> properly.  I was a little unclear on the docs reference to
> getRecordType().  As far as I'm concerned it should just return the default
> record type, but am not 100% sure about what this is.
>
> I was thinking of something like:
>
>         @Override
>         public Class<? extends R> getRecordType() {
>             return (Class<? extends R>) TableRecordImpl.class;
>         }
>
> But TableRecordImpl is one of those (Do not use, internal classes).  Is
> there a better option?
>
> Thanks.
>
> --
> 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.
>

-- 
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