I have 2 questions related to each other
Q1 What exactly is a transaction boundary in hibernate/Spring Data JPA. I am new to JPA , so please give a very basic example so I can understand as I tried to read multiple blogs but still not very clear.
Q2 And on top of it, what does this mean-
In hibernate, persist() method guarantees that it will not execute an INSERT statement if it is called outside of transaction boundaries, save() method does not guarantee the same.
What is outside and inside of a transaction boundary and how executions are performed outside boundaries?
CodePudding user response:
A transaction boundary it's where the transaction starts or is committed/rollbacked.
CodePudding user response:
When a transaction is started, the transaction context is bound to the current thread. So regardless of how many endpoints and channels you have in your Message flow your transaction context will be preserved as long as you are ensuring that the flow continues on the same thread. As soon as you break it by introducing a Pollable Channel or Executor Channel or initiate a new thread manually in some service, the Transactional boundary will be broken as well.
- some other people ask about it - look it up.
If you do not understand something write to me again more accurately and I will explain. I really hope I helped!