【发布时间】:2020-08-27 07:02:31
【问题描述】:
我使用 spring boot 开发了一个应用程序,我还使用 spring data jpa hibernate 我还使用 hikaricp 进行连接池。我需要知道每次 crud 操作后是否需要手动关闭连接?
模型、存储库、服务和控制器三层
@Override
public void delete(int id) {
try {
notificationRepository.deleteById(id);
}
finally {
//This code not working this is for explanation purpose and I need to know if I need to
//manually close connection then how can I do it
notificationRepository.close();
}
}
【问题讨论】:
-
不,你不应该。
-
这里的意见相同。它是自动管理的。
标签: java spring hibernate spring-data-jpa connection-pooling