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!

0

2 Answers 2

0

Change the property to hibernate.hbm2ddl.auto=create

Sign up to request clarification or add additional context in comments.

Comments

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.

2 Comments

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 ?
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)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.