I need to let Hibernate auto generate the database starting from the entities, however I want them all UPPERCASE.
This used to work in the past now I have messed up column names with Upper and Lower case letters.
I enabled the
.setProperty("hibernate.hbm2ddl.auto", "create")
to let Hibernate auto generate the database, and I created an UppercaseNamingStrategy.java extending org.hibernate.cfg.ImprovedNamingStrategy.
According to https://docs.jboss.org/hibernate/orm/5.0/manual/en-US/html_single/#configuration-namingstrategy
Now I should
You can specify a different strategy by calling Configuration.setNamingStrategy() before adding mappings:
SessionFactory sf = new Configuration() .setNamingStrategy(ImprovedNamingStrategy.INSTANCE) .addFile("Item.hbm.xml") .addFile("Bid.hbm.xml") .buildSessionFactory();
org.hibernate.cfg.ImprovedNamingStrategy is a built-in strategy that might be a useful starting point for some applications.
Configuration.setNamingStrategy() however seems to be no more in Hibernate 5.0.6.
I would of course like to do it programatically (I don't have .xml configuration files and don't want them).
NOTE:
Using
.setProperty("hibernate.ejb.naming_strategy", "my.project.hibernate.UppercaseNamingStrategy")
doesn't work as well, seems to be ignored altogether...