Menu

Insert Returning In JooqTemplate
πŸ“°

Insert Returning In JooqTemplate

DEV Community: javaΒ·ts5432Β·7 days ago
#4MTYxkGK
#devtojava#devto#dev#table#product
Reading 0:00
15s threshold

Using JooqTemplate requires no code generation and no XML configuration.

Add Dependency

gradle:

implementation 'net.sf.sprtool:sprtool-jooq:1.7.0'

Enter fullscreen mode

Exit fullscreen mode

maven:

<dependency> <groupId> net.sf.sprtool </groupId> <artifactId> sprtool-jooq </artifactId> <version> 1.7.0 </version> </dependency>

Enter fullscreen mode

Exit fullscreen mode

Inject JooqTemplate

import net.sf.sprtool.jooq.JooqTemplate ;

@Autowired private JooqTemplate jt ;

Enter fullscreen mode

Exit fullscreen mode

Using JooqTemplate

Inserting with a Table Object

Pass a jOOQ Table object built with DSL.table(...) as the first argument; the behavior is exactly the same as passing the table name string β€” with a partial-field insert, unset fields are null, and an empty Map also inserts 1 record:

import org.jooq.Table ; import org.jooq.impl.DSL ;

Table <?> productTable = DSL . table ( "product" );

Map < String , Object > product = new HashMap <>(); product .…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.