1

I am currently trying to implement an insert (see https://www.jooq.org/doc/latest/manual/sql-building/sql-statements/insert-statement/insert-returning/). The difference is that I don't use values ​​directly, but the set with record.

In the log I see that 2 inserts are executed, but in the Records Result there is always only 1 result. Test is with H2.

FooRecord foo1; FooRecord foo2; final Result<?> result = create.insertInto( FOO) .set( foo1 ) .set( foo2 ) .returningResult( FOO.ID ) .fetch(); 

What am I doing wrong?

1 Answer 1

1

Check the example of the INSERT .. SET documentation, which lists a call to newRecord(). You have to place a marker between your records to clearly distinguish between them:

final Result<?> result = create.insertInto( FOO) .set( foo1 ) .newRecord() // This call is necessary .set( foo2 ) .returningResult( FOO.ID ) .fetch(); 

Otherwise, the consecutive set() calls just override one another.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.