Announcement Announcement Module
Collapse
No announcement yet.
How is reattaching feature great for web tier? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.)

    Comment

    Working...
    X