You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Panache 2 (#46096) will make it (much) easier to switch from different paradigms to connect to databases through Hibernate: Session vs. StatelessSession, JDBC vs. reactive, ...
That's great, and is perfectly fine if you pick a single one of these options in each transaction, but can be dodgy if you use more than one of these options in a single transaction.
Here's the current situation as far as I know:
When in a (JTA) transaction and using Hibernate ORM, using both a Session and StatelessSession in the same transaction is fine (I told you the opposite @FroMage: I was wrong): the JDBC connection is shared at the Agroal level, and all connection requests during a single JTA transaction yield the same connection, so the Session and StatelessSession will just share their connection, and thus the same DB transaction.
When using Hibernate Reactive, using both a Session and StatelessSession in the same transaction is probably not fine at all: I suspect each will leverage an independent transaction. Conflicting updates will yield transaction rollbacks, and worse: rollback in one of the transactions will not trigger a rollback in the other one, leading to inconsistency in the DB. => It's fine now, see Hibernate Reactive: allow mixing Session and StatelessSession in the same transaction #52828
When using both Hibernate ORM and Hibernate Reactive in the same endpoint, ORM will enroll in a JTA transaction but Reactive will not: it will use non-JTA transactions. Conflicting updates will yield transaction rollbacks, and worse: rollback in one of the transactions will not trigger a rollback in the other one, leading to inconsistency in the DB.
I think we need to address this: at the very least document limitations, and perhaps even forbid using Hibernate Reactive and Hibernate ORM in the same endpoint, or forbid having a blocking (JTA) and reactive transaction scope active at the same time.
Description
Panache 2 (#46096) will make it (much) easier to switch from different paradigms to connect to databases through Hibernate:
Sessionvs.StatelessSession, JDBC vs. reactive, ...That's great, and is perfectly fine if you pick a single one of these options in each transaction, but can be dodgy if you use more than one of these options in a single transaction.
Here's the current situation as far as I know:
SessionandStatelessSessionin the same transaction is fine (I told you the opposite @FroMage: I was wrong): the JDBC connection is shared at the Agroal level, and all connection requests during a single JTA transaction yield the same connection, so theSessionandStatelessSessionwill just share their connection, and thus the same DB transaction.SessionandStatelessSessionin the same transactionis probably not fine at all: I suspect each will leverage an independent transaction. Conflicting updates will yield transaction rollbacks, and worse: rollback in one of the transactions will not trigger a rollback in the other one, leading to inconsistency in the DB.=> It's fine now, see Hibernate Reactive: allow mixing Session and StatelessSession in the same transaction #52828I think we need to address this: at the very least document limitations, and perhaps even forbid using Hibernate Reactive and Hibernate ORM in the same endpoint, or forbid having a blocking (JTA) and reactive transaction scope active at the same time.
Implementation ideas
No response