简体   繁体   English

使用JAVA UUID作为主键时,H2内存数据库错误“数据转换错误转换”

[英]H2 in-memory database error “Data conversion error converting” when using JAVA UUID as primary key

I got following error when using UUID generated by Java with Spring Data and uui2. 将Java生成的UUID与Spring Data和uui2一起使用时出现以下错误。 And different of other questions here, the UUID is generated by Java, not by the database. 与这里的其他问题不同,UUID是由Java而不是数据库生成的。

Caused by: org.h2.jdbc.JdbcSQLException: 
Data conversion error converting "X'aced00057372000e6a....72c41427e' 
(MYTABLE: FIELDID UUID NOT NULL)"; SQL statement:
insert into mytable (field1, filed2, fieldid) values (?, ?, ?) 
-- (?1, ?2, ?3) [22018-192]

I had 1.4.192 H2 Version on pom.xml. 我在pom.xml上有1.4.192 H2版本。

H2 Database got the following new feature on version 1.4.193 H2数据库在1.4.193版本上获得了以下新功能

PR #353: Add support for converting JAVA_OBJECT to UUID
http://www.h2database.com/html/changelog.html

So, I just needed to update my H2 Version on pom.xml to 1.4.193 or major to fix my problem. 因此,我只需要将pom.xml上的H2版本更新为1.4.193或主要版本即可解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM