java - JPA + Hibernate + CrudRepository flush? -


i want flush data, have following method

@requestmapping(value = "/add", method = requestmethod.post) @transactional public string musicsubmit(@modelattribute music music, model model) {     musicrepository.saveandflush(music);     model.addattribute("music", music);     return "result"; } 

my model

public interface musicrepository extends jparepository<music, integer> {  } 

my main

@springbootapplication public class application {      public static void main(string[] args) {         springapplication.run(application.class, args);     }  } 

my data visible if shutdown application , run again, disapears if set applications.properties this

spring.jpa.hibernate.ddl-auto = update 

how can keep data, if shutdown application or restart computer ?

use these in application.properties:

spring.datasource.url = jdbc:h2:file:~/some_path/yourverydbfile spring.datasource.username = sa spring.datasource.password = spring.datasource.driverclassname = org.h2.driver  spring.jpa.database = h2  spring.jpa.show-sql = true 

notice uses h2; if want else (mysql) should specify otherwise (and change values accordingly).

have here.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -