I am using hibernate with postgres / postgis. Since I switched the Hibernate property "hibernate.hbm2ddl.auto" from "update" to check if I got this exception:
Called: org.hibernate.HibernateException: wrong column type in history for type_id column. Found: int8, expected: int4
At first I thought that for hibernation, each link refers to another table as int8. I decided to change the type_id column to bigint without success. I have no ideas. Can anyone help?
My objects are structured like this:
@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; }
These are the table definitions in db:
History
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 | bigint | not null Indexes: "pk_history" PRIMARY KEY, btree (id) Foreign-key constraints: "fk_history" FOREIGN KEY (type_id) REFERENCES type(id)
A type
Column | Type | Modifiers -------------+-----------------------------+----------- id | bigint | not null cname | character varying(255) | created_on | timestamp without time zone | cunit | character varying(255) | Indexes: "type_pkey" PRIMARY KEY, btree (id) Referenced by: TABLE "history" CONSTRAINT "fk_history" FOREIGN KEY (type_id) REFERENCES type(id)
source share