我的问题类似于Postgresql UUID supported by Hibernate?,但我必须使用UUID数组。我收到错误消息
Caused by: org.postgresql.util.PSQLException: ERROR: column "system_ids" is of type uuid[] but expression is of type bytea
列定义为
@Column(name = "system_ids", columnDefinition = "uuid[]")
private UUID[] system_ids;
我正在使用Postgresql,所以我已将其他UUID pk映射为
@Type(type = "pg-uuid")
我不知道如何映射UUID []
答案 0 :(得分:0)
我找到了解决方案。由于某些问题,我正在使用hibernate 4.3.11.Final,并且无法使用typedef类UUIDArrayType.class,因此我将依赖项导入了pom.xml
<dependency>
<groupId>com.vladmihalcea</groupId>
<artifactId>hibernate-types-5</artifactId>
<version>2.9.13</version>
</dependency>
现在我的代码看起来像这样
...
@TypeDefs({
@TypeDef(name = "uuid-array", typeClass = UUIDArrayType.class) })
...
@Type(type = "uuid-array")
@Column(name = "system_ids", columnDefinition = "uuid[]")
private UUID[] system_ids;
...