You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Andre Juffer <aj...@sun3.oulu.fi> on 2005/10/31 21:02:42 UTC

pooling + hibernate

Hi all,

I am looking into the option to rely on an alternative pooling system 
for hibernate that the one provided by cocoon. I have employed (with 
success) the implementation as outlined in 
http://wiki.apache.org/cocoon/CocoonAndHibernateTutorial

However, this implementation results in a tight dependence upon cocoon, 
such that it appears to be a lot more difficult (if not impossible) in 
cocoon based web applications to persists objects from within layers 
that don't know anything about cocoon. At least, I cannot entirely see 
right know how exactly that would work as of yet.

Would there be any reason to assume that it is -not- a good idea to use 
two different pooling systems next to each other (cocoon and e.g. C3P0). 
Using a pooling mechanism other than that of cocoon seems to make it a 
lot easier to get to a org.hibernate.Session instance (e.g. with 
HibernateUtil, as documented on the Hibernate website, which effectively 
  employs the getCurrentSession() provided by 
org.hibernate.SessionFactory) virtually anywhere where access to the 
persistence layer is required.
Are there be issues related to the servlet filter for disposing 
Hibernate sessions (see the wiki). For the time being, I just want to 
use cocoon and hibernate and not an additional framework like swing or 
whatsoever.

Thanks,
Andre

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: pooling + hibernate

Posted by Andre Juffer <aj...@sun3.oulu.fi>.
Hi Johannes,

thanks for your reply.

 > Johannes Textor wrote:
> Hi  Andre,
> 
> even though it _is_ possible to persist objects from within layers that
> don't know anything about cocoon by propagating the connection pool in
> an InheritableThreadLocal, there is basically no reason why you
> shouldn't use an external C3P0 pool, and move all persistence related
> logic out of cocoon's sight (it is even cleaner design I think).
> 
> You could then modify the OpenSessionInViewFilter to open a hibernate
> session directly upon instantiation and would not need the additional
> avalon component used in wiki.

Well, I need to do some reading now to understand a few things ...

On the other hand, as you already pointed out, disconnecting the 
persistence logic from cocoon is a lot cleaner and definitely a better 
design and also makes it easier to test outside cocoon. I think I will 
go for that solution.

> 
> Feel free to contribute your findings to wiki btw :)

I'll keep that in mind.

Thanks,
Andre

> 
> Regards,
> Johannes
> 
> Andre Juffer schrieb:
> 
> 
>>Hi all,
>>
>>I am looking into the option to rely on an alternative pooling system
>>for hibernate that the one provided by cocoon. I have employed (with
>>success) the implementation as outlined in
>>http://wiki.apache.org/cocoon/CocoonAndHibernateTutorial
>>
>>However, this implementation results in a tight dependence upon
>>cocoon, such that it appears to be a lot more difficult (if not
>>impossible) in cocoon based web applications to persists objects from
>>within layers that don't know anything about cocoon. At least, I
>>cannot entirely see right know how exactly that would work as of yet.
>>
>>Would there be any reason to assume that it is -not- a good idea to
>>use two different pooling systems next to each other (cocoon and e.g.
>>C3P0). Using a pooling mechanism other than that of cocoon seems to
>>make it a lot easier to get to a org.hibernate.Session instance (e.g.
>>with HibernateUtil, as documented on the Hibernate website, which
>>effectively  employs the getCurrentSession() provided by
>>org.hibernate.SessionFactory) virtually anywhere where access to the
>>persistence layer is required.
>>Are there be issues related to the servlet filter for disposing
>>Hibernate sessions (see the wiki). For the time being, I just want to
>>use cocoon and hibernate and not an additional framework like swing or
>>whatsoever.
>>
>>Thanks,
>>Andre
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 


-- 
Andre H. Juffer              | Phone: +358-8-553 1161
The Biocenter and            | Fax: +358-8-553-1141
     the Dep. of Biochemistry | Email: Andre.Juffer@oulu.fi
University of Oulu, Finland  | WWW: www.biochem.oulu.fi/Biocomputing/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: pooling + hibernate

Posted by Johannes Textor <jc...@gmx.de>.
Hi  Andre,

even though it _is_ possible to persist objects from within layers that
don't know anything about cocoon by propagating the connection pool in
an InheritableThreadLocal, there is basically no reason why you
shouldn't use an external C3P0 pool, and move all persistence related
logic out of cocoon's sight (it is even cleaner design I think).

You could then modify the OpenSessionInViewFilter to open a hibernate
session directly upon instantiation and would not need the additional
avalon component used in wiki.

Feel free to contribute your findings to wiki btw :)

Regards,
Johannes

Andre Juffer schrieb:

> Hi all,
>
> I am looking into the option to rely on an alternative pooling system
> for hibernate that the one provided by cocoon. I have employed (with
> success) the implementation as outlined in
> http://wiki.apache.org/cocoon/CocoonAndHibernateTutorial
>
> However, this implementation results in a tight dependence upon
> cocoon, such that it appears to be a lot more difficult (if not
> impossible) in cocoon based web applications to persists objects from
> within layers that don't know anything about cocoon. At least, I
> cannot entirely see right know how exactly that would work as of yet.
>
> Would there be any reason to assume that it is -not- a good idea to
> use two different pooling systems next to each other (cocoon and e.g.
> C3P0). Using a pooling mechanism other than that of cocoon seems to
> make it a lot easier to get to a org.hibernate.Session instance (e.g.
> with HibernateUtil, as documented on the Hibernate website, which
> effectively  employs the getCurrentSession() provided by
> org.hibernate.SessionFactory) virtually anywhere where access to the
> persistence layer is required.
> Are there be issues related to the servlet filter for disposing
> Hibernate sessions (see the wiki). For the time being, I just want to
> use cocoon and hibernate and not an additional framework like swing or
> whatsoever.
>
> Thanks,
> Andre
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org