Hibernate version: 3.0.5
Mapping documents: Are certainly ok, so not included
Code between sessionFactory.openSession() and session.close(): the question is about this, so please read on
Name and version of the database you are using: MySQL 4.1
Browser: Firefox 1.0.6, Internet Explorer 6.0.1
Well, I'm trying to combine Hibernate with JSF and I have done the following:
1) In my mapping documents, I'm using the meta-attribute "generated-class" so that I could include own business logic in the class:
Code:
<meta attribute="generated-class">package..AbstractFooClass</meta>
In the class itself, I'm currently (and that's where things go wrong) using a state like
isSelected (set by the Presentation Framework in a HttpSession). Each time I submit something in my browser, I request the business objects from the HibernateSession (using the HibernateUtil class from the CaveAtEmptor project) and since sometimes the thread changes, the HibernateSession changes too. Thus, other business objects are retrieved from the HibernateSession, which means these have not set the desired state as I submitted it before. This also happens when I close the session of course, as I should do.
I am most certainly doing something seriously wrong, but I've been struggling with this for months now (no joking :s) and still haven't found a decent way to do it.
So a little recap, I need to put some application state in my business (I know, sounds wrong, but no idea of how to do it otherwise) objects that is not saved in the database, but I don't want to keep a session open as long as the HttpSession is still valid.
As far as I know, I should be doing the following (according to most documentation and tutorials): request the business objects, close the session and reattach the objects (which means I keep them somewhere in a Collection) when the user requests the page again. But that means I'm caching my business objects some way, while I'm pretty sure that this was done by the HibernateSession in Hibernate 2.1 (of which I migrated after which all the trouble started).
Hope someone could clarify this for me, because I can't make up what I have to do now from the documentation (guess I'm not as smart as I've always hoped to be).
Sincerely,
Benny 'Malavon' Goemans[/code][/i]