John
John

Reputation: 1337

If I restart the Rest server, H2 database reset

I used file db as below:

spring.datasource.url=jdbc:h2:file:./data/meet

And I can find file "meet.mv.db" in my working directory.

If I add tuples to the file and restart the server, the size of the file increases. However, I cannot get what is inside the file after restarting. That means there is no persistency at all.

Can anyone help me to find how to obtain persistency?

In case you need my source code: https://github.com/jihunim/meet_n_eat_server

Upvotes: 7

Views: 9679

Answers (3)

Use spring.jpa.hibernate.ddl-auto=update in application.properties.

Upvotes: 0

Thomas Decaux
Thomas Decaux

Reputation: 22671

In application.properties:

spring.jpa.hibernate.ddl-auto=update

(from https://docs.spring.io/spring-data/jpa/docs/1.4.3.RELEASE/reference/html/jpa.repositories.html)

Upvotes: 11

Pyrox
Pyrox

Reputation: 569

I ran into a similar problem and I discovered it was because I had this property set in the persistence.xml file:

<property name="hibernate.hbm2ddl.auto" value="create-drop" />

Removing this line fixed the issue and data was still there after server restart.

Upvotes: 5

Related Questions