0

I am using Spring transaction with hibernate jpa. I have one active transaction inside which i created a transaction using Propogation.RequiredNew how to make first transaction session data available in next transaction

rajatrj03
  • 13
  • 3

1 Answers1

0

Hibernate's Sessions can begin and commit several transactions. You need to ensure that your Hibernate session is kept open for the duration of the request rather than just for an individual transaction.

I don't the details of your implementation, I guess you can do one of the following;

  1. You can achieve this using the OpenSessionInView pattern. This will ensure your Hibernate session kept open for request rather for individual transaction.
  2. You can store the open session, but then you need to make sure it has no problem with concurrency as session objects are not thread safe.
fabfas
  • 2,200
  • 1
  • 21
  • 21