Wednesday, 11 September 2013

How to open transaction in Filter

How to open transaction in Filter

I use spring 3.2.4 and create a Filter. This Filter has to start the
transaction. In other words what I want to implement :
beginTransaction()
chain.doFilter(request, response);
endTransaction()
I tried to use @Transactional annotation with doFilter method but this
apparently does not work
(TransactionSynchronizationManager.isActualTransactionActive(); returns
false). Then I added OpenEntityManagerInViewFilter before my filter to
obtain the entityManager but
@PersistenceContext
EntityManager em;
still returns null. Is there any way to open the transaction in spring so
that transaction interceptor knows about it?

No comments:

Post a Comment