Best Practices for Retrieving DataContexts

From: Scott McClure (scot..martblob.com)
Date: Sun Jun 27 2004 - 14:51:06 EDT

  • Next message: Sat Nashikkar: "Re: Best Practices for Retrieving DataContexts"

    In the documentation, the suggested method for retrieving a DataContext is to
    store a DataContext in the HttpSession. While this works well, I do not want to
    pass my HttpSession into the DAO layer of my application, since it is not
    currently part of the DAO interfaces. At the same time, I do not want to
    retrieve a new DataContext for every method call. In Spring-Hibernate
    integration, this problem is solved by tying the Hibernate Session to the
    thread, and calling another SessionUtil class to either retrieve a session from
    the thread or create a new one. I do not think this will work as well in
    Cayenne due to the differences in Hibernate Sessions and Cayenne DataContexts.
    What is the best way to deal with this? Basically, the underlying goal is to
    implement a Cayenne DAO that is stateless and has no HttpSession passed in,
    without causing unnecessary overhead with too many DataContexts.

    In general, I would be interested to hear how people deal with DataContexts in a
    web application if it is different than the one-datacontext-per-session method.

    oh, btw, awesome project!

    Scott



    This archive was generated by hypermail 2.0.0 : Sun Jun 27 2004 - 14:51:04 EDT