2

I'm working on a project using maven, hibernate, spring and sqlite3.For the configuration of the connection and hibernate I use the application.yml file which is:

spring: 
profile: dev 
jpa:
hibernate:
ddl-auto: create-drop 
properties:
hibernate:
dialect: org.hibernate.dialect.SQLiteDialect
datasource:url: jdbc:sqlite:C:\Users\user pc\Desktop\database\testrest.db
username: username
password: password
driverClassName: org.sqlite.JDBC

The problem every time I start the application my sqlite database is overwritten (so I lose all my tables) and a new one of the same name is created.

Hoping to have your help, thank you in advance.

Nic3500
  • 8,144
  • 10
  • 29
  • 40
kasko
  • 131
  • 1
  • 4
  • 14
  • 1
    Possible duplicate of [how does exactly spring.jpa.hibernate.ddl-auto property works in Spring?](https://stackoverflow.com/questions/42135114/how-does-exactly-spring-jpa-hibernate-ddl-auto-property-works-in-spring) – Nic3500 Nov 15 '17 at 01:59

1 Answers1

2

The list of possible values for ddl-auto for Hibernate are:

  • validate: validates the schema, makes no changes to the database.
  • update: updates the schema.
  • create: creates the schema, destroying previous data.
  • create-drop: create the schema and then drop it when SessionFactory is closed explicitly (application is closed).

You should replace create-drop with update or validate

Sebastian D'Agostino
  • 1,575
  • 2
  • 27
  • 44