How to import initial data to database with Hibernate?

后端 未结 7 518
轻奢々
轻奢々 2020-11-27 11:06

When deploying applications, I often use Hibernate’s capacity to create database schema in order to simplify the deployment. This is easily achievable by configuring hiberna

7条回答
  •  隐瞒了意图╮
    2020-11-27 11:57

    After a couple of hours stumbling with this, I decided to share what I've found, though it's a very old post.

    To make it work properly, i had to do the following:

    • hbmddl set to create or create-drop
    • file.sql in classpath root; in my case, i just put it in resources folder, i'm using maven.
    • each sql command in one line
    • each file.sql must have a blank line at the beggining of the file ==> don't know the reason for this one, but if i don't insert that blank line, at the time of execution the servers tells me there's a syntax error near the first character.

    Hope that helps.

提交回复
热议问题