最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

h2 - UUID's size when migrate h2db to 2.3.232 from 1.4.200 - Stack Overflow

programmeradmin7浏览0评论

I have a script that transforms a PostgreSQL database into an H2 database.

Example of an entity with UUID:

@Entity
@Table(name = "app_language")
public class AppLanguage {

    @Id
    @GeneratedValue
    @UuidGenerator
    @Column(name = "app_language_id")
    private UUID id;
}

The UUID type is managed in PostgreSQL but not in H2, so the script modifies the UUID type to VARBINARY. No errors occur when inserting data into my database. In the database, the type of my app_language_id column is BINARY VARYING (size 36).

However, when I try to read data from the database, I get the following error:

Caused by: org.h2.jdbc.JdbcSQLDataException: Data conversion error "UUID requires 16 bytes, got 32"
Data conversion error converting "UUID requires 16 bytes, got 32" [22018-224]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:518)
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:489)
    at org.h2.message.DbException.get(DbException.java:223)
    at org.h2.message.DbException.get(DbException.java:199)
    at org.h2.value.ValueUuid.get(ValueUuid.java:69)
    at org.h2.value.Value.convertToUuid(Value.java:2462)
    at org.h2.value.ValueToObjectConverter.valueToObject(ValueToObjectConverter.java:304)
    at org.h2.jdbc.JdbcResultSet.getObject(JdbcResultSet.java:4196)
    at com.zaxxer.hikari.pool.HikariProxyResultSet.getObject(HikariProxyResultSet.java)
    at org.hibernate.type.descriptor.jdbc.UUIDJdbcType$2.doExtract(UUIDJdbcType.java:81)
    at org.hibernate.type.descriptor.jdbc.BasicExtractor.extract(BasicExtractor.java:44)
    at org.hibernate.sql.results.jdbc.internal.JdbcValuesResultSetImpl.getCurrentRowValue(JdbcValuesResultSetImpl.java:302)
    ... 114 common frames omitted
发布评论

评论列表(0)

  1. 暂无评论