Re: Child Contexts

From: Michael Gentry (mgentr..asslight.net)
Date: Tue Sep 21 2010 - 21:34:08 UTC

  • Next message: br..olos.pt: "Re: Child Contexts"

    Hi Bruno,

    In a typical deployment to Tomcat/JBoss/etc, you would use JNDI and
    let the container manage the database connections. It sounds to me
    like you are doing a lot of hot redeploys (not restarting Tomcat) and
    somehow the resources aren't being cleared up correctly for you. With
    JNDI, the container should manage the database connection externally
    to your hot redeploy.

    JNDI doesn't actually return a DataContext, but it'll return a
    database connection to a DataContext. And the DataContext will give
    it back to Tomcat's connection pool when done. There are numerous
    settings for Tomcat on how to manage the database connection pool for
    you. Usually you would tell it to keep at least 1 open connection
    (minIdle) to the database, but that is configurable by you. Check the
    Tomcat docs for setting it up.

    mrg

    On Tue, Sep 21, 2010 at 5:07 PM, <br..olos.pt> wrote:
    > I'm using the regular way, through the Cayenne's DataNode XML file. But I
    > am open to suggestions :). I was thinking about configuring a global
    > resource on tomcat using JNDI that would return a DataContext, but i dont
    > know if everytime an application access the resource a new object is
    > created?
    >
    > Thank you
    >
    >> What are you using to provide your DB Connection Pool: JNDI, DBCP, or
    >> Cayenne?  What version of Cayenne are you using?
    >>
    >> mrg
    >>
    >>
    >> On Tue, Sep 21, 2010 at 3:03 PM,  <br..olos.pt> wrote:
    >>> Hey Michael and Robert,
    >>>
    >>> Ok so i got the difference between context and connection. So how can i
    >>> close all connections before closing an application, a servlet or a
    >>> portlet? My main problem here is that on each deploy of a new web
    >>> application the connections from former deployments stay on (like memory
    >>> leaks), and i need to close them or at least use one pool for the whole
    >>> site.
    >>>
    >>> I was thinking about putting the Context on the HTTPSession of the
    >>> application server or making a context that is used permanently by the
    >>> server... Any ideas how to do it on liferay or tomcat?
    >>>
    >>> Thank you
    >>> Bruno
    >>>
    >>>> Hi Bruno,
    >>>>
    >>>> The Child DataContext *might* share the same database connection as
    >>>> the Parent DataContext.  In general, you don't care about this,
    >>>> though.  The DataContext, on commitChanges(), will request a database
    >>>> connection, use that connection for performing the commit, then return
    >>>> the connection back to the pool.  It isn't required that the same
    >>>> database connection be used between a performQuery() and a
    >>>> commitChanges().
    >>>>
    >>>> If you do commitChanges() on a Child DataContext, it pushes the
    >>>> changes to the Parent DataContext and to the database.  If you only
    >>>> want the changes to go to the Parent DataContext and *not* the
    >>>> database, use commitChangesToParent().
    >>>>
    >>>> mrg
    >>>>
    >>>>
    >>>> On Tue, Sep 21, 2010 at 2:22 PM,  <br..olos.pt> wrote:
    >>>>> Hello all,
    >>>>>
    >>>>> Do Child Contexts share the connection of a parent connection? When i
    >>>>> do
    >>>>> a
    >>>>> commitChanges on the child the change is made on the database or in
    >>>>> the
    >>>>> parent? I have already read the Nested Contexts page on the User Guide
    >>>>> but
    >>>>> this detail was confusing for me.
    >>>>>
    >>>>> Thank you
    >>>>> Bruno
    >>>>>
    >>>>>
    >>>>
    >>>
    >>>
    >>>
    >>
    >
    >
    >



    This archive was generated by hypermail 2.0.0 : Tue Sep 21 2010 - 21:34:59 UTC