Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails - ORA-02275 - such a referential constraint already exist

Does anyone knows if there's a way for Grails to check if a referential constraint he is trying to create already exists?

Unfortunately, I can't drop the database and create it again, because of the enviroment in wich it is and my company policy, size of the database, etc.

It throws me an error that I would not want it to exist in production enviroment:

[main] ERROR hbm2ddl.SchemaUpdate  - Unsuccessful: alter table <TABLE> add constraint <CONSTRAINT> foreign key (<FK>) references <THEOTHERTABLE>
[main] ERROR hbm2ddl.SchemaUpdate  - ORA-02275: such a referential constraint already exists in the table.

Edit: This happened when I tried to correct the name of a Table column that is a foreign key from another table.

Oracle 10g Grails 1.3.9

like image 646
Johnny C. Avatar asked Dec 19 '25 20:12

Johnny C.


1 Answers

Use hibernate.hbm2ddl.auto=validate. This will not try to makes any change in your schema, just "validate" what you map in your POJOs with the database schema.

Also you can set your logger to "debug" level and you will check what Hibernate is doing.

like image 130
Walter Colchado Avatar answered Dec 22 '25 09:12

Walter Colchado



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!