• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unclear, how to use detached objects in web apps ?

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
As you know, one of Hibernate's powerfull points is the ability to pass detached objects to presentation layer then reassociate them in another transaction.
I was thinking about this approach , but I was unable to understand how to pass these detached objects to another session again.
I mean we pass detached to presentation layer for displaying purposes (we put these detached objects in request scope for example then forwards the request to JSP page).
Some one enlight me please ?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, let's first remove the Web stuff out of the equation, because it is the same even if you had a Swing front end. The main point is the Session. You open a Session, and while you query and load objects that are attached to the Session, once you close it, the reference you have is now detached. At some point later you can open a new Session, and re-attach the reference to the Session so that it is once again being managed by the Session. One thing that you will need to do is have a version field so that Hibernate can determine if you have a stale object or not.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic