0

I'm currently facing some confusion using Hibernate. At the moment Im using repositories and QueryDsl to build and execute my queries. Im confused when it comes to get a JDBC from the pool to perform DB operations. I understood the concept of write-behind cache that the persistence context is providing, but what I dont really understand is when a JDBC connection is actually requested from the pool, used for DB operations and then release.

Thank you

Green
  • 376
  • 5
  • 15
  • Hi @crizzis thank you for your reply. Now I have another question... I have an application doing batch jobs. To improve performance I multithreaded it by diving the jobs in smaller pieces to be run in parallel. However, there is an extraction phase which requires db connection and it could happen that the connections are not available in the pool. Should the thread block till a new connection is available? Because at the moment it is throwing an exception – Green Oct 06 '20 at 18:40
  • Well, it usually depends on the configuration of the datasource. Check the documentation of the datasource implementation you're using for timeout settings. For interactive threads, timeouts are *a good thing*, but perhaps your scenario simply needs the timeout setting to be tweaked a little. Or maybe, some form of synchronization between the threads would eliminate the problem. Hard to tell without knowing the exact scenario – crizzis Oct 06 '20 at 18:50
  • @crizzis Thank you again for your reply. Ok, I was thinking that a request to a connection pool with no connections available at a given moment would block till a new connection is available again. – Green Nov 18 '20 at 07:54
  • Well, it normally would, but not indefinitely so, because no timeout would lead to potential deadlock/starvation problems – crizzis Nov 18 '20 at 09:47
  • @crizzis Yes, actually, we were using the standard datasource configs. Thank you! – Green Jan 05 '21 at 11:20

0 Answers0