Hibernate + Tomcat - where to bind the session to?

voigt_at_ynnor.de
Date: 02/10/05

  • Next message: voigt_at_ynnor.de: "Re: Comparing database dates: SELECT FROM WHERE Date(today) < MYDATECOL ?"
    Date: 10 Feb 2005 10:52:32 -0800
    
    

    Hello group,

    I am building a web application with Tomcat and Hibernate as O/R
    mapper. Now my question is where should I bind the session to?

    At the moment I have the Hibernate Session as a ThreadLocal, so for
    each thread a new HibernateSession is created. Another possibility
    would be to bind the hibernateSession to the httpSession, so each user
    has his/her own Hibernate session. Does this make sense? How much mem
    would this take up per user? Perhaps it makes it easy to DOS the
    server?

    Another thing which is related to the above thoughts: is it OK to
    store a persistent object in the HTTPSession temporarily for some
    time? What if hibernateSession from thread A fetches the object,
    thread B changes it and thread C calls saveOrUpdate() ? Will this
    break my app or will it work?

    I am a bit confused about this and looking forward to your answers :)

    Greetings
    Bastian Vogit


  • Next message: voigt_at_ynnor.de: "Re: Comparing database dates: SELECT FROM WHERE Date(today) < MYDATECOL ?"

    Relevant Pages

    • Hibernate die richtige Wahl =?ISO-8859-15?Q?f=FCr_mich=3F?=
      ... Ich möchte mich mal mehr in die Programmierung "richtiger" Java ... Anwendung geteilte Session factory? ... Wenn ich versuche Hibernate nur in möglichst niedrigen Schichten zu ...
      (de.comp.lang.java)
    • Re: [Hibernate] wechselnde Fehler bei Update
      ... Denn ich kann mir nicht vorstellen, dass man Objekte nicht ordentlich upgedatet bekommt nur weil lazy loading aktiv ist. ... Der TilesController holt sich bei der Factory die Session. ... Ich würde Dir ein Buch wie Hibernate in Action empfehlen, das diesen Herbst auch in einer Neuauflage rauskommt und dann Hibernate 3 behandelt. ...
      (de.comp.lang.java)
    • Hibernate all processes in a KDE desktop?
      ... be able to suspend a single process and then shut down my ... It would be handy to be able to hibernate all processes running as my ... I use KDE 3.5.5. ... On Login and selected "Restore manually saved session". ...
      (alt.os.linux)
    • Re: J2EE (websphere) + Hibernate + ThreadLocal
      ... According to Hibernate team the standard way to use hibernate in a J2EE ... environement (on a session per request basis) is with the HibernateUtil ... Therefore you must leave the thread in a good state for the next request. ...
      (comp.lang.java.programmer)
    • Re: J2EE (websphere) + Hibernate + ThreadLocal
      ... According to Hibernate team the standard way to use hibernate in a J2EE ... environement (on a session per request basis) is with the HibernateUtil ...
      (comp.lang.java.programmer)