Results 1 to 2 of 2

Thread: How is reattaching feature great for web tier?

  1. #1

    Default How is reattaching feature great for web tier?

    Hi.

    Im using Hibernate and lots of times Ive read that Hibernate's feature to reattach object is cool, because object can be for eg. updated to db after it has returned from UI layer where is has been changed as detached.

    It sounds cool, but web is stateless, and when I load data object from db to present fields as form fileds, I cannot pass it down to data tier for update when Submit is pressed. All I see in web request controller after submit is ID of this db row, thus I have to load it again, and update then, right? If web would be statefull, then instance would be kept constantly in UI layer, and reattached when needed.

    Or am I wrong?

    -Vjeran

  2. #2

    Default

    There are a couple of benefits to holding a reference to a detached object across user requests. One is that you don't have to take the performance hit of reloading the object from the database. Another is that you can support things like optimistic locking. For example, if the row in the database changes before the user submits a change of her own, you won't be able to detect it if you just reload the object, set the fields, and save it. (Unless you implement some kind of version check yourself.)

    The web tier doesn't necessarily have to be stateful, either. After all, you could serialize the entire object rather than just the ID and send it to the client. (Spring might provide some support for this. I don't know. I haven't worked on the web tier at my current company.)

Similar Threads

  1. Replies: 2
    Last Post: Oct 10th, 2005, 05:12 PM
  2. Spring in a multi tier (portal) enviroment
    By jherbst in forum Architecture
    Replies: 1
    Last Post: Jul 20th, 2005, 01:35 AM
  3. Separate Web Tier and Business Logic tier.
    By dcioccar in forum Architecture
    Replies: 14
    Last Post: May 13th, 2005, 03:46 AM
  4. Hibernate reattaching useless in web tier
    By vmarcinko in forum Web
    Replies: 0
    Last Post: Jan 7th, 2005, 02:46 AM
  5. Replies: 1
    Last Post: Dec 16th, 2004, 03:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •