I want to make a desktop application using JavaFx, Spring Boot and Spring Data JPA with H2 as my database . The problem is that I am trying to run Junit to save data locally in a directory but every time I run Junit the data is being lost.
My application.properties
file;
spring.output.ansi.enabled=ALWAYS
spring.datasource.url=jdbc:h2:mem:test;
DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;
spring.datasource.platform=h2
spring.datasource.username = sa
spring.datasource.password =
spring.datasource.driverClassName = org.h2.Driver
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.jpa.generate-ddl=true
My test case;
HotelEntity hotelEntity = new HotelEntity(1, "Name", "Password", "MobileNumber", "email");
hotelDao.save(hotelEntity);
System.out.println("Hotel Dao--");
List<HotelEntity> hotelEntities = hotelDao.findAll();
System.out.println(hotelEntities.size());
It print the list size is 1 but when i run test case again like this
List<HotelEntity> hotelEntities = hotelDao.findAll();
System.out.println(hotelEntities.size());
It print the list size is 0