Search code examples
javamysqllinuxpersist

MySQL tables are empty after restarting Linux application


I am using hibernate to persist entity objects in a local running database.

Everything is working fine (connecting to the database, add/delete/update entries), as long as the application is running.

I am using this code to pass the entry to a table:

CrudRepository:

public interface ArticleRepository extends CrudRepository<ArticleEntity, Integer> {
}

DB accessor method:

public void addArticleEntity(ArticleEntity articleEntity){
    articleRepository.save(articleEntity);
}

After restarting the application all the entries are gone, only the empty table itself is persisted permanently.

How can I save these table entries permanently?


Solution

  • Sorry for posting such random information, I simply had no idea where to start searching. Even tho, downvoting did not help.

    The solution was to set spring.jpa.hibernate.ddl-auto=create (which obviously create new tables on restart) to spring.jpa.hibernate.ddl-auto=update.

    Probably it'll help someone looking for similar terms.