Custom sql at the begin of every transaction

Hello,

I use Flowable within a spring boot application. Can I use some existing hooks to execute app-specific SQL statements at the begin of every transaction?

Background: In PostgreSQL, you can change the database user per transaction, using the command ‘SET LOCAL ROLE’. I want to change user because I use PostgreSQL-provided access control features to restrict users’ access to model classes.

Thank you very much,
Timo

It’s quite low level, but one way could be to plug in a custom DbSqlSessionFactory (https://github.com/flowable/flowable-engine/blob/master/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/db/DbSqlSessionFactory.java), that does something on the connection in the #openSession method. Haven’t tried it, but in theory that should do trick.