我正在使用postgres/postgis进行休眠.当我从"update"切换Hibernate属性"hibernate.hbm2ddl.auto"以验证我得到了这个异常:
引起:org.hibernate.HibernateException:列type_id的历史记录中的列类型错误.找到:int8,预期:int4
首先我认为hibernate需要对另一个表的每个引用都是int8.我选择将列type_id更改为bigint但没有成功.我没有想法.有人可以帮忙吗?
我的实体以这种方式构建:
@Entity
public class History{
@Id
protected Integer id;
private Date created_on;
private Date timestamp;
@ManyToOne
private DataType type;
private Double value;
}
@Entity
public class DataType{
@Id
private Integer id;
private String cname;
private Date created_on;
private String cunit;
}
Run Code Online (Sandbox Code Playgroud)
这些是db中的表定义:
历史
Column | Type | Modifiers
------------+-----------------------------+-----------------
id | integer | not null default nextval('history_id_seq'::regclass)
created_on | timestamp without time zone |
timestamp | timestamp without time zone |
value | double precision |
type_id …Run Code Online (Sandbox Code Playgroud)