插入不要返回多个生成的ID
我目前正在尝试实现插入(请参阅 https://www.jooq.org/doc/latest/manual/sql-building/sql-statement/insert-statement/insert-statement/insert-ertert-returning/ )。不同之处在于,我不直接使用值,而是带有记录的集合。
在日志中,我看到执行了2个插入物,但是在记录结果中总是只有1个结果。测试与H2。
FooRecord foo1;
FooRecord foo2;
final Result<?> result =
create.insertInto( FOO)
.set( foo1 )
.set( foo2 )
.returningResult( FOO.ID )
.fetch();
我在做什么错?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查
插入.. set
文档,列出了调用newRecord()
的调用。您必须在记录之间放置标记,以清楚区分它们:否则,连续的
set()
调用只是互相覆盖。Check the example of the
INSERT .. SET
documentation, which lists a call tonewRecord()
. You have to place a marker between your records to clearly distinguish between them:Otherwise, the consecutive
set()
calls just override one another.