Reputation: 304
I've developed an application using spring boot and I also use spring data jpa hibernate I also use hikaricp for connection pooling. I need to to know do I need to manually close the connection after every crud operation ?
there are three layers model , repository, service and controller
@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();
}
}
Upvotes: 0
Views: 3178
Reputation: 1491
Well nice to meet a SLIIT undergraduate , Answer to your question is closing the connection will handle automatically .If you close your connection after every operation then your application performance will be decrease heavily.Only thing you want to ensure is usage of @Transactional annoation in your business(Service) layer,apart from that you don't wan't do anything manually.
Upvotes: 1