Quantcast
Channel: Java Programming Forum - Learn Java Programming - Hibernate
Viewing all articles
Browse latest Browse all 76

Does performance issue for each request getting the session and close the session?

$
0
0
Team,
I need a clarification about session performance. I have created session pool(LocalSessionFactoryBean). I mean for each thread request I am getting a session(not created new one) from pool. For each request(from controller to serviceImpl), I am getting a session and once request is completed I just close the session. In this case, I feel session(currentSession and close session) is cause of performance issue for following ways. Please suggest me, which way is best in this situation.

#WAY 1:
=======
TestController.java
-------------------------
for (String sdgCode : sdgCodes) {
//For each sdgCode, I am calling serviceImpl
// As per my knowledge, We are getting a session / close the session for each service request
for (Feature sdgFeature : planService.getSharedDataGroupsFeature(sdgCode)) {

}
}

#WAY 2:
=======
TestController.java
------------------------
//One serviceImpl request and get the all feature objects
//Only one session will play the role here. Only one time close the session.
List<Feature> features = planService. getSharedDataGroupsFeatures(sdgCodes);
for (Feature sdgFeature : features ){

}

Conclusion : Is it performance issue for each time getting the session from session pool and close the session for each request once request has been completed? Please suggest me…

Viewing all articles
Browse latest Browse all 76

Trending Articles