Hi Giuseppe

A lot of methods in jOOQ depend on the meta data of your tables / fields.
Ideally, you will be using the code generator, which produces this meta
data for you. If you use the plain SQL API, there is no way how jOOQ could
possibly know what fields are contained in a given table, so your call to
DSLContext::newRecord cannot work this way, because jOOQ doesn't know what
fields to associate values from your POJO with.

The error you're getting happens earlier. You're unsafely casting a generic
org.jooq.Record type to a BatchRecord type, which you probably got from the
code generator.

But why are you using the plain SQL API in the first place? Just pass the
BATCH table reference to dsl.newRecords(BATCH, batchPOJO). Perhaps you
intended for the schema name to be changed dynamically from the generated
schema to something else, at runtime? We have an entire feature for that:
https://www.jooq.org/doc/latest/manual/sql-building/dsl-context/custom-settings/settings-render-mapping/


I hope this helps,
Lukas

On Mon, Mar 30, 2020 at 12:04 AM [email protected] <[email protected]> wrote:

> Sorry for mistake my code are:
>
> BatchRecord br = (BatchRecord) dsl.newRecord(DSL.*table*(DSL.*name*(
> "schema", Batch.*BATCH*.getName())) , batch);
>
> dsl.insertInto(DSL.*table*(DSL.*name*("schema", Batch.*BATCH*
> .getName()))).set(br).onDuplicateKeyUpdate().set(br).execute();
>
>
> the error are:
>
> java.lang.ClassCastException: class org.jooq.impl.RecordImpl cannot be
> cast to class it.ieo.dao.jooq.codegen.dc1.tables.records.BatchRecord
> (org.jooq.impl.RecordImpl and
> it.ieo.dao.jooq.codegen.dc1.tables.records.BatchRecord are in unnamed
> module of loader 'app')
>
> Il giorno dom 29 mar 2020 alle ore 23:13 Rob Sargent <
> [email protected]> ha scritto:
>
>> And exactly what problem are you having?
>>
>> On Mar 29, 2020, at 2:24 PM, nome cognome <[email protected]> wrote:
>>
>> Hi everyone,
>> i have a question, i want to put data in db using:
>>
>> *public* Table<?>  = DSL.*table*(DSL.*name*(schema, Batch.*BATCH*
>> .getName()));
>> BatchRecord br = dsl.newRecord(tablesFields.batchTable , batchPOJO);
>> dsl.insertInto(Batch.*BATCH*
>> ).set(br).onDuplicateKeyUpdate().set(br).execute();
>>
>> but i have some problem  with dsl.newRecord
>>
>> how i do to resolve?
>> thanks
>> Giuseppe
>>
>> --
>> 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].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/jooq-user/5853ba15-4919-4939-90b3-bdcb849274d9%40googlegroups.com
>> <https://groups.google.com/d/msgid/jooq-user/5853ba15-4919-4939-90b3-bdcb849274d9%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>>
>> --
>> 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].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/jooq-user/918B7BB5-0DD1-4924-8196-AE1B7C40E710%40gmail.com
>> <https://groups.google.com/d/msgid/jooq-user/918B7BB5-0DD1-4924-8196-AE1B7C40E710%40gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> 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].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jooq-user/CAO6DE2kESwBBr3XYxKM9e%3DXPo3-ZCKYO2enzh%2Bur85WwWqEY%3DQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/jooq-user/CAO6DE2kESwBBr3XYxKM9e%3DXPo3-ZCKYO2enzh%2Bur85WwWqEY%3DQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jooq-user/CAB4ELO5XCcYA%3DAFQXYPi5eBpQEHbjy8TXYizDFGU2QOStKB2Pw%40mail.gmail.com.

Reply via email to