Reputation: 19559
I have two method and they are all annotation-ed @Transactional.
I know that those two method will execute in two different transaction.
But are those two methods be executed in ONE hibernate session?
spring transaction manager keeps will the session on until the end of the http request?
I know the transaction manager may do something like this in it's aop proxy:
Session session=sessionFactory.openSession/getCurrentSession;
Transaction tx=session.beginTransaction();
...
tx.commit();
I just cannot find the code, If I can find the code in somewhere, I can answer this question by myself.
Upvotes: 2
Views: 133
Reputation: 124441
spring transaction manager keeps will the session on until the end of the http request?
No it won't. The transaction manager knows nothing about a http request, it only knows about the start and end of the transaction (which is thread bound). The Session
will be destroyed and cleaned as soon as the transaction ends.
That is unless you are using the OpenSessionInViewFilter
(or interceptor) then the Session
will be kept open until the request has been handled.
Upvotes: 2