Configure Hibernate 4 Application
spring.jpa.hibernate.ddl-auto = update spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.DefaultComponentSafeNamingStrategy
Hibernate 5 app setup
spring.jpa.hibernate.ddl-auto = update spring.jpa.hibernate.naming.implicit-strategy = org.hibernate.boot.model.naming.ImplicitNamingStrategyComponentPathImpl spring.jpa.hibernate.naming.physical-strategy = org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
Tables and columns are generated according to the old model , but by changing the names of keywords .
So, I have a:
org.hibernate.tool.hbm2ddl.SchemaUpdate : HHH000228: Running hbm2ddl schema update Unable to execute schema management to JDBC target [alter table acidentepessoal_cruz_em add constraint FKddk6qn84r6c1kyhukvffaleao foreign key (emCruzamentos_id) references CruzamentoEm] ORA-02275: such a referential constraint already exists in the table
When ddl-auto update , the framework tries to create another FK because hibernate 5 generates another FK name from the previous version.
I tried to extend ImplicitNamingStrategyComponentPathImpl and delegate the generation of the FK name to DefaultComponentSafeNamingStrategy . I was surprised when I realized that this only handles the names of tables and columns.
How to do it? How to use sleep mode for 4 foreign keys in Hibernate 5? How to upgrade from Hibernate 4 to 5 when using ddl-auto = update?
source share