spring has implemented itw own opensessioninview filter.,
i dont' think that you have to crete your own

Spring has a class like this which you can declare in your web.xml
OpenSessionInViewFilter

On Thu, May 7, 2009 at 2:29 AM, Christian Helmbold
<christian.helmb...@yahoo.de> wrote:
>
> Hello,
>
> I want to use the Open Session In View Pattern with Wicket, but I don't want 
> to open a Hibernate Session for every request like the ServletFilter approach 
> does.
>
> I looked at the "lazy-loading Open Session in View" for JPA implementation 
> from Wille Faler. 
> http://faler.wordpress.com/2009/04/30/building-a-more-scalable-open-session-in-view/
>  He uses AOP instead of a ServletFilter to intercept only those method calls 
> that need an EntityManager.
>
> My plan is to build something similar for Hibernate with Spring AOP. The 
> solutions would consist of the following steps:
>
> 1. An aspect creates a new Hibernate Session, if a method is called, that 
> needs one and none is already open.
> 2. The transaction runs.
> 3. The RequestCycle commits the transaction and closes the session. Or 
> rollback, if an exception was thrown.
>
> Is something wrong with it?
>
> The Hibernate Reference says: "When the transaction ends, either through 
> commit or roll back, the "current" Session is closed automatically."
> https://www.hibernate.org/42.html#A6
>
> This means that only one transaction can be executed in one request, right? 
> But what is, if I need more than one transaction per request? Since I have to 
> hold the session open during rendering, because of lazy loading, I cannot 
> commit a transaction if I don't know another Session will be opened 
> immediately and not to be closed until the end of the request cycle.
>
> Hibernate typically bounds the Session to the current thread. But was is the 
> current thread in a Wicket Application? Are those threads pooled? Could the 
> same session be used in two requests, when no commit happened?
>
> Thanks in advance,
> Christian
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to