【发布时间】:2011-05-28 13:41:36
【问题描述】:
我无法让 Hibernate 使用 java.util.UUID for PostgreSQL。
这是使用 javax.persistence.* 注解的映射:
private UUID itemUuid;
@Column(name="item_uuid",columnDefinition="uuid NOT NULL")
public UUID getItemUuid() {
return itemUuid;
}
public void setItemUuid(UUID itemUuid) {
this.itemUuid = itemUuid;
}
当持久化一个瞬态对象时,我得到一个 SQLGrammarException:
column "item_uuid" is of type uuid but expression is of type bytea at character 149
PostgreSQL 版本是 8.4.4
JDBC 驱动程序 - 8.4.4-702(也尝试过 9.0 - 同样的事情)
Hibernate版本是3.6,主要配置属性:
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.url">jdbc:postgresql://192.168.1.1/db_test</property>
【问题讨论】:
标签: java hibernate postgresql orm hibernate-mapping