The Hibernate folks are a lot more excited about long sessions and detached objects than I am. (It's hard not to get attached to a fun feature once you've implemented it!) Personally, I think they make the app harder to write: there's much more worrying about stale data and scalability. For many apps, caching give the same kinds of performance benefits with fewer programmer headaches and hidden concurrency issues.

The session-per-request model is probably the simplest and easiest default to start with. I like to begin there, keeping in mind the other options, thinking carefully about where transaction boundaries need to be -- and then depart from session-per-request when specific situations require something different.

Cheers,

Paul


On Jan 11, 2006, at 1:20 AM, <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> wrote:

I just went thru Hibernate In Action (edition 1), chapter 8.2 (Implementing Application Transactions). This chapter talks about the two options we talked about, and a third option: Long Session.

It seems that "Hibernate in Action" recommends Long session on a web application over other two. The next preferred option is "Detached Persistent Object Strategy" (same as option 1 in my original email).

Will this new information change your opinions on these options?

Thanks ....

Shovon

----- Original Message ----
From: Patrick Casey <[EMAIL PROTECTED]>
To: Tapestry users <[email protected]>
Sent: Tuesday, January 10, 2006 6:40:29 PM
Subject: RE: Best Practice (Hibernate, Spring, Tapestry)


I'd generally be inclined to go with Option #2. Loading an object in
session A, then reattaching it to session B (with, for example,
Session.lock()) is a bit of a code smell with hibernate, especially if
there's any chance the object might have been changed by another thread
between initial load and reattachment.

Likewise there's the issue that if you're storing the whole thing in
the HTTPSession that burns memory *and* requires that all your POJO's
implement serializable.

All in all, I'd go with key and reload; it's what I do about 95% of the time except for a few special cases where I need to keep the object and
session between screen renders, in which case I just store store the
Hibernate session in the HTTPSession (which I wouldn't recommend as a
general case solution).

    --- Pat
[EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



_________________________________________________________________
Piano music podcast: http://inthehands.com
Other interesting stuff: http://innig.net



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to