Working with the application.properties file

1

See my application..properties file:

 spring.jpa.database=POSTGRESQL
  spring.datasource.platform=postgres
  spring.jpa.show-sql=true
  spring.jpa.hibernate.ddl-auto=create-drop
  spring.database.driverClassName=org.postgresql.Driver
  spring.datasource.url=jdbc:postgresql://localhost:5432/money?createDatabaseIfNotExist=true&useSSL=false
  spring.datasource.username=postgres
  spring.datasource.password=1234

What is happening is that every time when I go to execute the project it gives a drop in the table and then create the table everything again, and with that it erases all the records that exist in the bank as you can see below; p>

This is below a SpringTools log, it's because my project is a Spring Boot

Hibernate: drop table if exists categoria cascade
Hibernate: create table categoria (codigo  bigserial not null, nome varchar(255), primary key (codigo))
[2m2017-11-14 13:24:14.127[0;39m [32m INFO[0;39m [35m4076[0;39m [2m---[0;39m [2m[  restartedMain][0;39m [36morg.hibernate.tool.hbm2ddl.SchemaExport [0;39m [2m:[0;39m HHH000230: Schema export complete

How do I configure the file to not do this?

I tried with this snippet of code, but I was not successful.

?createDatabaseIfNotExist=true&useSSL=false
    
asked by anonymous 14.11.2017 / 17:32

1 answer

2

Hello, this property should not be of this value:

 spring.jpa.hibernate.ddl-auto=create-drop

In this case it will always "drop" the table and recreate. I recommend if you want to keep the data remove this property from your properties (comment)

    
14.11.2017 / 17:49