Hello ,
I am using JPA with Hibernate as the Persistence provider .
I have a working example and I wanted to try out a few changes .
One of them was ::
Code:
<property name="hibernate.hbm2ddl.auto" value="[b]validate[/b]"/>
I changed this attribute to "validate" ( earlier it was "update" )
The DDL that I ran when I created the tables is :: ( using Postgres DB )
Code:
create table Master4(id int,name varchar);
create table Child4(childid int,street varchar,id int);
alter table master4 add constraint p_k_k5 PRIMARY KEY (ID);
alter table child4 add constraint f_k_k5 FOREIGN KEY(ID) REFERENCES MASTER4(ID);
Now whenever I run the example I get the following exception ::
Code:
Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.HibernateException: Wrong column type: childid, expected: int8
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:720)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:121)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
at com.onetoone.postgres.ChildContainsParent.Client.main(Client.java:15)
Caused by: org.hibernate.HibernateException: Wrong column type: childid, expected: int8
at org.hibernate.mapping.Table.validateColumns(Table.java:261)
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1083)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:116)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:317)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:713)
Regards,
~satish[/code]