I got some sleep and looked for it elsewhere. It turned out the query that 
"didnt" happen was called internally and not from a request so obviously 
not covered by the filter.

I was dead certain that the problem was the SingletonScope of the filter.. 
but what do you know :) Thanks for the help!

On Wednesday, September 19, 2012 11:43:58 PM UTC+2, scl wrote:
>
>  For me the code looks good.
> What do you need the Provider<EntityManger> for?
>
> To test if the @Transactional has an effect or not you can place a 
> breakpoint in JpaLocalTxnInterceptor in the method invoke(). If your code 
> hits this method a transaction will be started (if non is already running).
>
>
>
>
> On 09/19/2012 06:16 PM, Johannes wrote:
>  
> Hi, 
>
>  I have followed the advise on 
> http://code.google.com/p/google-guice/wiki/JPA and it seems to work when 
> I set @Transactional directly on my DAO. However, I have trouble 
> implementing this in a transaction-per-request fashion. My first attempt is 
> to use a filter:
>
>  @Transactional
>>
>> class TransactionFilter implements Filter {
>>
>>
>>  final Provider<EntityManager> entityManager;
>>
>>  @Inject
>>
>> public TransactionFilter(Provider<EntityManager> entityManager) {
>>
>>  this.entityManager = entityManager;
>>
>> }
>>
>>  @Transactional
>>
>> @Override
>>
>> public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain 
>> arg2) throws IOException, ServletException {
>>
>>  arg2.doFilter(arg0, arg1);
>>
>> }
>>
> Bound AFTER:
>
>> filter("/*").through(PersistFilter.class);
>
> in my module. It just does not seem to have an effect.
>
>  How do people ensure one transaction per request in a servlet 
> environment ?
>
>  Kind regards
> Johannes 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "google-guice" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/google-guice/-/EJByN5WHgnIJ.
> To post to this group, send email to google...@googlegroups.com<javascript:>
> .
> To unsubscribe from this group, send email to 
> google-guice...@googlegroups.com <javascript:>.
> For more options, visit this group at 
> http://groups.google.com/group/google-guice?hl=en.
>
>
>  

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-guice/-/bAeVmPXjlqsJ.
To post to this group, send email to google-guice@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.

Reply via email to