Hi Joseph,
a very well established best practice in using cocoon flow (flowscript
or javaflow) with Hibernate is the so-called CHS
(Cocoon-Hibernate-Spring) approach first introduced here [1]. Of course
it requires for your project to rely/depend also on Spring, but I think
that this can only be a plus, also because of the very recent release of
Spring 2.0.
As properly described here [2] (these slides were presented both in
Cocoon GetTogheter and ApacheCon) you should:
1. Declare your persistence objects (Hibernate persistence manager,
datasource and DAO) in the spring applicationContext
2. Load the context via contextListener in the web.xml
3. Load your (transactionally wrapped) service via flow using a Spring
facility and load/use your services easily
Integrating Hibernate and Spring is probably the most common Spring
usage scenario so you should find plenty of docs in the web (e.g. [3]).
HTH,
Gabriele
PS.
Working with this approach may lead you to some problems while using
continuations (and his request/response cycle wrapping) AND hibernate
lazy loading, because of the premature closure of the session. If this
is your case, to solve it you may have a look at this [4], where a
HibernateFlowAdapter is provided.
[1] http://cocoondev.org/main/117/43.html?layoutType=plain
[2] http://agylen.com/wp-content/Ugo_Cei_ApacheCon_2005EU.pdf
[3] http://www.springframework.org/docs/wiki/Spring_AOP_with_Hibernate.html
[4] http://www.nabble.com/Flow-and-hibernate-sessions-t1232967.html
Andre Juffer ha scritto:
Joseph,
you could have a look at:
http://www.hibernate.org/42.html (especially
http://www.hibernate.org/42.html#A11)
http://www.hibernate.org/43.html
The SessionFactory is created only once in an interceptor
(http://www.hibernate.org/43.html#A3) where also the transaction is
started and committed. I do not use flow to create the SessionFactory.
To access the session, I depend on the repository pattern where the
current session is obtained from the SessionFactory.
Hope this helps,
Andre
Joseph Toman wrote:
I was wondering if anyone had advice or opinions on
using Hibernate+Flow+Cocoon? I'm writing a small test
application to understand the issues involved, and I'm
not quite clear where the SessionFactory should be created.
According to the Hibernate documentation it's a relatively expensive
operation, so I don't want to do it each time the flowscript runs.
Ideas, or things that have worked for you would be greatly appreciated.
J. Toman
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Gabriele Columbro
Consultant at Sourcesense Italy
--
email: [EMAIL PROTECTED]
blog: http://www.mindthegab.com
mobile: (0039)3201612846
yahoo: g.columbro
gtalk: [EMAIL PROTECTED]
AIM: gabrielecolumbro
--
"Keyboard not found. Press F1 to continue"
--
begin:vcard
fn:Gabriele Columbro
n:Columbro;Gabriele
email;internet:[EMAIL PROTECTED]
tel;cell:00393201612846
x-mozilla-html:TRUE
version:2.1
end:vcard
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]