I have Spring Boot application with implemented RESTController
s. In the RESTController I specified /clients/
endpoint (PUT
method) to update client resource.
In my database (PostgreSQL) I have implemented several triggers on the client
table to record history of the changes to the client_history
table. The problem is that I need to insert author (user_id
) of the changes to the client_history
table.
This question (https://stackoverflow.com/a/13172964) led me to use GUC inside my trigger function.
select current_setting('custom.application_user_id'))
Now I need to execute sql query set custom.application_user_id = {user_id};
to set user_id when Hibernate opens new session. I have tried to use Hibernate Interceptors to do this, but this solution does not work.
Could someone give me an example how to subscribe to the event when session is created?
P.S. Also I have silly question: Does every HTTP requests received by the application creates (obtains from connection pool) new connection?