The structure of my program is as follows:
Inside my main java class:
for () // this will execute for say 5000 times
{
// do select on Database1 (this will select say 10000 rows)
// do some computations (mainly string operations)
call function1() // this will do some update on Database1
}
Now I am trying to access Database1 using Hibernate. My question is how to use a sleep session to access it. When should I start a session, and when should I end it?
If I run it before the for () loop, can I pass the same session to function1 () because it is accessing the same database? Or as soon as I make a choice (LINE 1), do I need to close it and open a new session in function1 ()? Optimizing overall performance and minimizing overall execution time is my main concern.
I am new to Hibernate. So please forgive me if I ask very stupid doubts.