Re: Cayenne Article on

From: Andrus Adamchik (
Date: Wed Jun 09 2004 - 11:21:57 EDT

  • Next message: Andrus Adamchik: "Re: Cayenne Article on"

    On Jun 9, 2004, at 2:47 AM, Marko Kocic wrote:
    >> On Jun 8, 2004, at 11:40 AM, Marko Kocic wrote:
    >>> No, I don't put DataContext in session/visit, I just fetch it for
    >>> each
    >>> service method invocation (see interceptor bellow).
    >> This may have undesirable side effects. If you want to work with
    >> object
    >> relationships, related objects must be registered with the same
    >> DataContext. Of course you can fetch all needed objects on every
    >> request, but this seems wasteful. The most efficient use of Cayenne in
    >> a web app is when a DataContext spans the whole session.
    > Thanx for insight. I just wanted to use DataContext the same way I used
    > Connection, fetch it from DataSource when I need it, use it, and close
    > when I don't need
    > it anymore.

    DataContext is different from Connection, DataSource, etc. I discussed
    it a bit in the TSS article. That's the beauty if it - you don't have
    to "close" or otherwise "manage" it.

    > Sure I want to use relationships. So you suggest I should have one
    > DataContext per user for performance reasons? What if I have say 500
    > logged in users?
    > Does each DataContext maintain its own object cache, or cache is
    > shared between
    > contexts? I'm concerned about memory.

    This a common tradeoff of any caching system - memory vs. speed. You
    can tweak it though. When memory becomes a problem (Never been a
    problem for me yet), you can clean up DataContext cache, or set it to
    null conditionally (not on every request, but in places where you want
    to do cleanup).

    > I'm still playing with Cayenne, so IMHO something like "best
    > practices" info
    > would be great.

    Things about DataContext are all in the user guide, and Tapestry/Struts
    tutorials. There is always room for improvement of course...

    > btw [off topic]
    > Cayenne is a great framework (at least what I found so far). Modeler
    > is what
    > bought me to
    > Cayenne :). But it stll has some (non technical) issues where it is far
    > behind hibernate. Just
    > look at the hibernate site, it's full of examples and tutorials (h +
    > spring, h + webwork,
    > h + tapestry, h + struts, h + BMP beans, h + jboss...).

    We provide Tapestry, Struts and (primitive) JBoss/Session EJB examples.
    But I agree that we need more. The thing is, myself and other Cayenne
    committers may not be the best experts in every single framework
    available out there. For instance I am using Cayenne/Tapestry and
    hardly need EJB for anything at all. We need more community help!

    So please (and this is a request to all Cayenne users), when you use
    Cayenne in some new environment, or think you've discovered some
    patterns not mentioned in the docs, submit a simple example via this
    list or our bug/feature tracker. This will help others immensely!

    Marko, your HiveMind examples is a very good start. I am sure you'll
    have it updated and extended when you start using Cayenne on the actual


    This archive was generated by hypermail 2.0.0 : Wed Jun 09 2004 - 11:22:03 EDT