i have an application thats build on Spring boot, using JPA repositories on HSQL database.
Problem is that while application is running, I create an entity,and it's persisted correctly to database(can be seen in database manager). But after application shutdown from eclipse, all data is removed;
Saving is performed like this
@Service
public class NotificationService {
@Autowired
private NotificationRepository notificationRepository;
public void notifyRefreshArticles(){
Notification notification = new Notification();
notification.setCreatedAt(LocalDateTime.now());
notification.setNotificationSeverity(NotificationSeverity.NORMAL);
notification.setNotificationType(NotificationType.REFRESH_ARTICLES);
notificationRepository.save(notification);
}
}
I pretty sure its configuration issue,but with spring boot basically only configuration that i have is this configuration file.
spring.datasource.driver-class-name=org.hsqldb.jdbc.JDBCDriver
spring.datasource.url=jdbc:hsqldb:hsql://localhost/rr_app_database
spring.datasource.username=XXXXXX
spring.datasource.password=XXXXXX
spring.datasource.show-sql=true
Do you have hbm2ddl text somewhere in your configuration properties. It should be set to update
or none
, apparently you might have create-drop
.
Specify a local filename in application.properties data source URL:
spring.datasource.url=jdbc:hsqldb:file:/home/username/testedb
You can remove the spring.datasource.driver-class-name
property as Spring Boot detects it by URL property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With