0
我使用JPA(休眠)与Postgres数据库,我的休眠数据库配置情况如下:PostgreSQL的JPA架构验证9.5
properties.setProperty("hibernate.dialect", "org.hibernate.dialect.PostgreSQLDialect");
properties.setProperty("hibernate.hbm2ddl.auto","validate");
我有一个表属性created_by_user_id
CREATE TABLE dppm_main.user_account_profile
(....//other columns
created_by_user_id integer
)
映射到JPA实体如下:
@Column(name = "created_by_user_id")
private Long createdByUserId;
在做模式验证时,我g以下错误:
org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: wrong column
type encountered in column [created_by_user_id] in table [user_account_profile];
**found [int4 (Types#INTEGER)], but expecting [int8 (Types#BIGINT)]**
我该如何解决?我在很多地方都有这个问题,所以可以通过扩展PostgreSQL82Dialect
而不是columnDefinition来修复它。
非常相似[错列式“表“列找到:int8,expected:int4](http://stackoverflow.com/questions/27230426/wrong-column-type-in-table-for-column-xy-found-int8-expected-int4) –
我知道没有关于JPA的消息,但是错误消息表明它期望列被定义为'bigint',因为你的JPA实体使用'Long'。试着在JPA实体中使用'Integer'或者在表格定义中使用'bigint'。 –