Under the hood, Table grid Editor (TGE) uses Hibernate as an ORM and c3p0 connection pool manager to manage connections to databases (DBs).
Info | |
---|---|
title | Hibernate, SessionFactories, Connection Pools and SessionsHibernate allows to talk to a DB through Sessions, which are acquired from so called Session Factories. A SessionFactory defines where (to which DB) and how (via what connection, connection pooling properties) do the Sessions talk to DBs. Also each SessionFactory is assigned with a connection pool, from which the connections are acquired from. The Sessions allow one to execute queries to the DB. |
...
Each time a user opens a page with a TGE field, or uses JQL search with TGE JQL functions, or defines a datasource spec, a request is sent to the JIRA server, which then builds a grid according to the grid configuration (or datasource specification). When the grid is built, the configurations for hibernate (and thus to the connection pool manager) are created. Whenever the grid needs any data from it's datasources, the Hibernate Session Factories are looked up in TGE Hibernate Session Factory Cache:
...
if the SessionFactory is found, it is used to create Sessions to talk to the database. Also, the SessionFactory gets assigned with a timestamp
(discussed later on), set to current time
if the SessionFactory is not found, it is created from the configurations and stored to the TGE Hibernate Session Factory Cache. Also, the SessionFactory gets assigned with a timestamp
(discussed later on), set to current time
...
then, each of the SessionFactories (in the TGE Hibernate Session Factory Cache) is checked whether current time minus 15 minutes is more than the timestamp (was the SessionFactory used within the last 15 minutes)
if current time minus 15 minutes is lesser than or equal to the timestamp (SessionFactory was used within the last 15 minutes), nothing happens
if current time minus 15 minutes is more than the timestamp (SessionFactory was not used within the last 15 minutes), the SessionFactory is closed (which implicitly asks the connection pool manager to close connections) and removed from the TGE Hibernate Session Factory Cache.
then, the SessionFactory is used to create a Session to talk to a datasource. When the Session is closed, it releases the connection, so that other Sessions could use it.
The default Hibernate configuration is the following:
...