atomikos / transactions-essentials

Development repository for next major release of
https://www.atomikos.com/Main/TransactionsEssentials
Other
461 stars 139 forks source link

Diff Session in JDBC and Hibernate #204

Open jashan0360 opened 9 months ago

jashan0360 commented 9 months ago

Description In Spring application, I am using spring-boot-started-jta-atomikos version 2.6.4 dependency for transactions. I have created an interface to use jdbc and hibernate both. While using the query to fetch the sessionId of connection in both jdbc and hibernate it looks like they are using different sessions to connect. Not only this, But if I am trying dml/updation queries on normal tables via jdbc it is also reflected in the hibernate query for normal tables, if they have different sessions then why is it happening, is it due to local session commit?. I am facing problem in executing statements for the global temporary tables, updations/insertion done by jdbc is not reflected in the hibernate which i want to see. Is there any way to have the same sessionId within a single job having multiple DB operations? If yes, then how, If not then how this should be go for GlobalTemp tables as they are working for the normal tables.

To Reproduce Steps to reproduce the behavior:

-> I am trying to do some operations via procedure on global temp tables and that operations should be reflected to hibernate also. -> Also used hibernate logs: [TRACE] o.h.i.SessionFactoryImpl$SessionBuilderImpl - Opening Hibernate Session. tenant=null [DEBUG] o.h.r.t.b.j.i.JtaTransactionCoordinatorImpl - Hibernate RegisteredSynchronization successfully registered with JTA platform [TRACE] org.hibernate.internal.SessionImpl - Opened Session [18c3ee06-bb7d-4cf9-90da-bdf79ff74a2c] at timestamp: 1704368982687 -> expect the updations/DMLs done in single transaction is visible to all within scope of job. -> using spring-boot-started-jta-atomikos version 2.6.4. Also tried to use some properties like local-transaction-mode=true and serial-jta-transactions=true

Properties used: allowSubTransaction=false

Additional context Previously using bitronix I ve found this different sessionId but could be solved by using property share-transaction-connections = true. Is there any property/configuration in atomikos to handle this scenario?