I realize that Swing is a presentation framework and Hibernate is an ORM technology for simplifying the data layer. I realize that the two have little to do with each other. Still I have a question that I can't find a straightforward answer to.
I need to render an object, say a Thing object. When the user clicks on the visual representation of the Thing object, I need to call myThing.getContents() which should return a Set of persistent objects. I want the set to be lazy loaded. Therefore, when the user clicks on myThing, I need to attach myThing to a session (using
Code:
Session.lock(myThing,LockMode.NONE)
I assume), then call getContents(), then detach, etc.
Is there a good pattern to be used here? The app I'm working with is too far along to go back and put in an AOP container or something cool like that so that I can use interceptors or something of that sort.
Is there a simple way to manage Hibernate Sessions so they are available without putting any knowledge of session management into any of my Swing code?