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