0

I have hibernate set up in my spring project, once the tables are created in my database it works no problem, however I want my hibernate to automatically create my tables for me. I am not using xml for the configuration I am using application.properties file and a hibernateConfig.java class.

application.properties

hibernate.format_sql = true
hibernate.dialect=org.hibernate.dialect.HSQLDialect
hibernate.show_sql=true
hibernate.hbm2ddl.auto=update

HibernateConfig.java

  private Properties hibernateProperties() {
    Properties properties = new Properties();
    properties.put("hibernate.dialect", environment.getRequiredProperty("hibernate.dialect"));
    properties.put("hibernate.show_sql", environment.getRequiredProperty("hibernate.show_sql"));
    properties.put("hibernate.format_sql", environment.getRequiredProperty("hibernate.format_sql"));
    properties.put("hibernate.hbm2ddl.auto", environment.getRequiredProperty("hibernate.hbm2ddl.auto"));


    return properties;        
}

Any suggestions would be greatly appreciated!

R-B
  • 7
  • 4
lulubelle
  • 31
  • 7

2 Answers2

0

Change the property to hibernate.hbm2ddl.auto=create

0

Take a look at https://docs.spring.io/spring-boot/docs/current/reference/html/howto-database-initialization.html and set the property hibernate.dbm2ddl.auto=create.

That should solve the problem.

Kai Adelmann
  • 199
  • 6
  • 15
  • I have changed it to this but it is now giving me an error saying it could not extract result set and it is still not creating the tables... any suggestions ? – lulubelle Mar 13 '18 at 16:47
  • That would be a totally different problem, which you should post in a seperat question, as this one is apparently solved. Furthermore, we would need some more code to judge about that sort of problem (namely the model etc. you're trying to autocreate) – Kai Adelmann Mar 14 '18 at 09:08