Hibernate naming strategy


I am building a REST webservice with Spring (Boot) and am trying to use hibernate as orm mapper without any xml configuration.

I basically got it to work, but I am stuck with a configuration issue. I instantiate LocalContainerEntityManagerFactoryBean as @Bean in a @Configuration file. I set hibernate.ejb.naming_strategy as in the following example -> this seems to work for creating the tables if they do not exist (column names are camelCase like in my @Entity classes) but when a query is executed, hibernate "forgets" about this naming configuration and tries to use another kind of naming strategy with under_score_attributes --> obviously those queries fail. Is there any other property I need to set? Or another way of configuring the properties preferably without adding a cfg.xml or persistence.xml?

LocalContainerEntityManagerFactoryBean lef = new LocalContainerEntityManagerFactoryBean();   
Properties props = new Properties();
props.put("hibernate.hbm2ddl.auto", "create");
By : Alex


I got the solution now.

@EnableAutoConfiguration(exclude={HibernateJpaAuto Configuration.class}) 

The JpaAutoConfiguration must be excluded. Still I think this might be a bug, as normally it should automatically "stand back" when I use my own @Configuration.

By : Alex

Have you tried setting this particular property using programmatic properties? Or a hibernate.properties file in the package root? Or a JVM system property? All are described here.

From my experience, there are sometimes difficult to diagnose Hibernate problems if you insist on not using any XML (which would be my preference as well). If nothing else works, you may be forced to define a configuration file at least.

This video can help you solving your question :)
By: admin