4

I need get the transaction id of hibernate. This id must be unique for each transaction. I tried to use the session.getTransaction().hashCode(), but i believe that this value is not unique.

Smiderle
  • 447
  • 3
  • 12
  • Can you explain your use-case, what are you trying to do? – mabi Jun 15 '15 at 12:27
  • Are you using Spring or any other frameworks? – Jet Jun 15 '15 at 12:40
  • When a record (and your relationships) is removed from the database will be saved in an audit table. At some point, it will be possible to undo the deletion all tables that were removed in a given transaction. I'm not using any framework. Just hibernate. – Smiderle Jun 15 '15 at 12:44

1 Answers1

1

Transaction id is database specific. So you will need to invoke native SQL query to get this information from within your transaction in Hibernate.

Examples:

Get current database transaction id using jdbc/hibernate?

SQL Server Triggers - grouping by transactions

http://hemantoracledba.blogspot.com/2014/06/getting-your-transaction-id.html

Community
  • 1
  • 1
codedabbler
  • 1,183
  • 6
  • 12