[jboss-user] [JBoss Seam] - release connection after lazy init in view

imario do-not-reply at jboss.com
Tue May 22 09:24:53 EDT 2007


Hi!


I would like to know if seam handle (if at all) the following problem:
(BTW: I looked at the source, but couldn't find something in this direction)

You load an entity from the database which has a lazy OneToMany within.
Now, when you do not access this list from your action class or any other managed code the session will be disconnected and the underlaying Connection will be passed back to the pool.
Fine!

Now, when your JSF page iterate through the lazy list the Session will be automatically reconnected - a new Connection will be borrowed - to fetch the data from the database.

But now, no one knows that this happened ... no one passes back this Connection to the pool.
The request finished and the Connection is still alive in the Session.

Its not that a big problem, though, it cost some resources especially if you have to wait until the end of a conversation to release the Connection again.


Is there something I oversee? Do you know how to deal with?


One solution I have in mind is a new Hibernate ConnectionReleaseMode  - something like: ConnectionReleaseMode.AFTER_TRANSACTION_OTHERWISE_ALWAYS

This means something like: If within a transaction release the connection after it, otherwise release the connection after each statement.
Such a lazy init issued by the view will most likely be outside of any transaction ... so this could work - even if it just works with Hibernate.

Or a way to change the ConnectionReleaseMode during the lifetime of the Session.

Thanks!
Ciao,
Mario

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4047576#4047576

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4047576



More information about the jboss-user mailing list