3
votes

During the startup of Jboss server, I get the following stacktrace. I wonder why JPA is trying to alter tables that seem to be fine and how to get passed these ERROR messages. Thanks

2009-08-03 11:28:49,683 ERROR [org.hibernate.tool.hbm2ddl.SchemaUpdate] Unsuccessful: alter table BDPARAMS add constraint FK61733C48FA34BFDC foreign key (ITEMID) references RTELEMENT 2009-08-03 11:28:49,683 ERROR [org.hibernate.tool.hbm2ddl.SchemaUpdate] Unsuccessful: alter table BDPARAMS add constraint FK61733C48FA34BFDC foreign key (ITEMID) references RTELEMENT 2009-08-03 11:28:49,683 ERROR [org.hibernate.tool.hbm2ddl.SchemaUpdate] ORA-02275: such a referential constraint already exists in the table

2009-08-03 11:28:49,683 ERROR [org.hibernate.tool.hbm2ddl.SchemaUpdate] ORA-02275: such a referential constraint already exists in the table

2009-08-03 11:28:49,745 ERROR [org.hibernate.tool.hbm2ddl.SchemaUpdate] Unsuccessful: alter table CONTENTITEM add constraint FK692B5EEC44F32395 foreign key (parent_id) references CONTENTLOCATION 2009-08-03 11:28:49,745 ERROR [org.hibernate.tool.hbm2ddl.SchemaUpdate] Unsuccessful: alter table CONTENTITEM add constraint FK692B5EEC44F32395 foreign key (parent_id) references CONTENTLOCATION 2009-08-03 11:28:49,745 ERROR [org.hibernate.tool.hbm2ddl.SchemaUpdate] ORA-02275: such a referential constraint already exists in the table

4
What RDBMS do you use? What is the setting of your hibernate.hbm2ddl.auto value?Daff
I use Oracle 11 G and I use update for hibernate.hbm2ddl.auto. FYI even though it displays these errors application is deployed properly and it works fine. But I want to fix this error.maddy

4 Answers

4
votes

In my case, the problem solved when I added the default_schema name to Hibernate configuration file:

<property name="hibernate.default_schema" value="db_default_schema_name" />

Specifically, in Play framework 2.4, I added the above line to conf\META-INF\persistence.xml file.

Hibernate version used: 4.3.11

1
votes

In my case the error messages occoured after I changed the java package structure in my project. I think hibernate was a bit confused about that.

I had similar errors (alter table ... add constraint) and I am using Oracle DB 10g. For me the easiest solution was to export the data of the concerned tables (inserts), delete them, start the application which creates the tables again, and then import the table data again. Then Hibernate creates the tables again by itself and the error messages are gone!

1
votes

I had the same error but fixed it with a few simple steps.

Dump the current database Mysqldump out current.sql Change hibernate.cfg to create so it recreates the database table Dump the new database Mysqldump out new.sql

Copy the create table new to current reinsert database mysql in current.sql

1
votes

I've had similar errors and the problems stem from inaccuracies in the meta data fetch by the jdbc sub-system. The meta data comes back to tell hibernate the constraint is not there but in reality it is not - could be for a number of reasons. I would suggest trying a different dbms also maybe the issue is due user differences between current and user that generated the table. There could also be something wrong with your mapping.

But ultimately the only fool proof way to fix it is to turn off schema sync on startup.