MySQL tables are empty after restarting Linux application [closed]
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?
java mysql linux persist
closed as off-topic by Mureinik, Madhur Bhaiya, jww, Mike M., Makyen Nov 17 '18 at 5:11
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – jww, Makyen
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
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?
java mysql linux persist
closed as off-topic by Mureinik, Madhur Bhaiya, jww, Mike M., Makyen Nov 17 '18 at 5:11
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – jww, Makyen
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
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?
java mysql linux persist
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?
java mysql linux persist
java mysql linux persist
edited Nov 17 '18 at 3:49
jww
54.1k41234513
54.1k41234513
asked Nov 16 '18 at 12:02
elpelp
364116
364116
closed as off-topic by Mureinik, Madhur Bhaiya, jww, Mike M., Makyen Nov 17 '18 at 5:11
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – jww, Makyen
If this question can be reworded to fit the rules in the help center, please edit the question.
closed as off-topic by Mureinik, Madhur Bhaiya, jww, Mike M., Makyen Nov 17 '18 at 5:11
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – jww, Makyen
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
The persist method is intended for adding a new entity instance to the persistence context, i.e. transitioning an instance from transient to persistent state.
We usually call it when we want to add a record to the database (persist an entity instance):
Person person = new Person();
person.setName("John");
session.persist(person);
For more information:
https://www.baeldung.com/hibernate-save-persist-update-merge-saveorupdate
add a comment |
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.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The persist method is intended for adding a new entity instance to the persistence context, i.e. transitioning an instance from transient to persistent state.
We usually call it when we want to add a record to the database (persist an entity instance):
Person person = new Person();
person.setName("John");
session.persist(person);
For more information:
https://www.baeldung.com/hibernate-save-persist-update-merge-saveorupdate
add a comment |
The persist method is intended for adding a new entity instance to the persistence context, i.e. transitioning an instance from transient to persistent state.
We usually call it when we want to add a record to the database (persist an entity instance):
Person person = new Person();
person.setName("John");
session.persist(person);
For more information:
https://www.baeldung.com/hibernate-save-persist-update-merge-saveorupdate
add a comment |
The persist method is intended for adding a new entity instance to the persistence context, i.e. transitioning an instance from transient to persistent state.
We usually call it when we want to add a record to the database (persist an entity instance):
Person person = new Person();
person.setName("John");
session.persist(person);
For more information:
https://www.baeldung.com/hibernate-save-persist-update-merge-saveorupdate
The persist method is intended for adding a new entity instance to the persistence context, i.e. transitioning an instance from transient to persistent state.
We usually call it when we want to add a record to the database (persist an entity instance):
Person person = new Person();
person.setName("John");
session.persist(person);
For more information:
https://www.baeldung.com/hibernate-save-persist-update-merge-saveorupdate
answered Nov 16 '18 at 12:10
AbhishekAbhishek
396117
396117
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Nov 16 '18 at 12:32
elpelp
364116
364116
add a comment |
add a comment |