Hibernate behavior with C3P0


The application uses Hibernate 4.3.11 with C3P0 for connection pooling. The max connection pool size is configured in hibernate.cfg.xml file. In this case, if the number of open sessions (open database connections) reaches the max size configured, then the next call to SessionFactory.openSession() will wait until the connection becomes available in the c3p0 pool and the thread calling the openSession method will proceed only when the connection becomes available in the pool?

The Connection acquisition request will block, but that’s not necessarily related to openSession. It depends on the underlying transaction type: JTA or RESOURCE_LOCAL.