gpt4 book ai didi

java - Springs SimpleJdbcInsert 不会按预期生成自动生成的键

转载 作者:太空宇宙 更新时间:2023-11-04 08:40:17 26 4
gpt4 key购买 nike

我正在使用 springs SimpleJdbcInsert 执行 JDBC 插入返回 2 个自动生成的键。

我使用的命令是:

KeyHolder keys = insert.withTableName("TRANSACTION").usingGeneratedKeyColumns("TRANSACTIONID", "ROWID").executeAndReturnKeyHolder(params);

但是keys只包含一个名为SCOPE_IDENTITY()的键

日志似乎表明一切进展顺利,只是 TRANSACTIONID 和 ROWID 自动生成的键未填充,以下是一些相关日志

DEBUG o.s.jdbc.core.simple.SimpleJdbcInsert  - JdbcInsert not compiled before execution - invoking compile
DEBUG o.s.jdbc.core.metadata.TableMetaDataProviderFactory - Using GenericTableMetaDataProvider
DEBUG o.s.jdbc.core.metadata.TableMetaDataProvider - GetGeneratedKeys is supported
DEBUG o.s.jdbc.core.metadata.TableMetaDataProvider - GeneratedKeysColumnNameArray is supported for H2
DEBUG o.s.jdbc.core.metadata.TableMetaDataProvider - Retrieving metadata for PRIMARY.DB/PUBLIC/TRANSACTION
DEBUG o.s.jdbc.core.metadata.TableMetaDataProvider - Retrieved metadata: TRANSACTIONID 4 false
DEBUG o.s.jdbc.core.metadata.TableMetaDataProvider - Retrieved metadata: CREDITS 3 true
DEBUG o.s.jdbc.core.metadata.TableMetaDataProvider - Retrieved metadata: TXNTYPE -6 true
DEBUG o.s.jdbc.core.metadata.TableMetaDataProvider - Retrieved metadata: CARDTXNID 12 true
DEBUG o.s.jdbc.core.metadata.TableMetaDataProvider - Retrieved metadata: DATE 93 true
DEBUG o.s.jdbc.core.metadata.TableMetaDataProvider - Retrieved metadata: ROWID 4 false
DEBUG o.s.jdbc.core.metadata.TableMetaDataProvider - Retrieved metadata: CARDINFOID 4 true
DEBUG o.s.jdbc.core.metadata.TableMetaDataProvider - Retrieved metadata: PAYMENTMETHOD -6 true
DEBUG o.s.jdbc.core.metadata.TableMetaDataProvider - Retrieved metadata: USERID 4 true
DEBUG o.s.jdbc.core.simple.SimpleJdbcInsert - Compiled JdbcInsert. Insert string is [INSERT INTO TRANSACTION (CREDITS, TXNTYPE, CARDTXNID, DATE, CARDINFOID, PAYMENTMETHOD, USERID) VALUES(?, ?, ?, ?, ?, ?, ?)]
DEBUG o.s.jdbc.core.simple.SimpleJdbcInsert - JdbcInsert for table [TRANSACTION] compiled
DEBUG o.s.jdbc.core.simple.SimpleJdbcInsert - The following parameters are used for call INSERT INTO TRANSACTION (CREDITS, TXNTYPE, CARDTXNID, DATE, CARDINFOID, PAYMENTMETHOD, USERID) VALUES(?, ?, ?, ?, ?, ?, ?) with: [10, 2, 64H80073VY322412Y, 2011-03-30 14:05:12.526, null, 2, null]
DEBUG o.s.jdbc.core.JdbcTemplate - Executing SQL update and returning generated keys
DEBUG o.s.jdbc.core.JdbcTemplate - Executing prepared SQL statement
DEBUG o.s.jdbc.core.simple.SimpleJdbcInsert - Using generated keys support with array of column names.
DEBUG o.s.jdbc.core.JdbcTemplate - SQL update affected 1 rows and returned 1 keys

最佳答案

这是我正在使用的 H2 数据库的问题。它不支持返回多个自动生成的 key 。

关于java - Springs SimpleJdbcInsert 不会按预期生成自动生成的键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5483139/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com