[hibernate-dev] Post-connect queries for 6.1?

Jordan Gigov coladict at gmail.com
Mon May 13 08:38:24 EDT 2019


I thought it would be good to have an API that will call any registered
queries upon connecting to the database, and maybe ones before returning it
to the connection pool.
I'm thinking it should be called in the implementations of ConnectionProvider
and MultiTenantConnectionProvider.

The basic purpose would be so you can set certain parameters. For example
in setting the timezone in PostgreSQL:

SET SESSION TIME ZONE 'UTC';

Or in MySQL:

SET SESSION time_zone = 'Europe/Berlin';

This would of course require dialect handling, and access to some of the
configuration settings given to the SessionFactory.
There should also be a way for users to customize these with a
per-persistence-unit configuration of some sort. They might want to pass
other such runtime tweaks.
Someone may want to send something like this to their MySQL:

SET SESSION sql_mode = 'TRADITIONAL,ANSI';

I realize it's too late to think about this for 6.0, but it's something to
consider for later on.


More information about the hibernate-dev mailing list