Re: a query does not see newly inserted objects?

From: Michael Gentry (mgentr..asslight.net)
Date: Tue Oct 12 2010 - 13:50:26 UTC

  • Next message: Marc Guenther: "Re: Required cayenne dependencies not available in maven central"

    Hi Marc,

    Until you commit the user to the DB, your query (which goes against
    the DB) isn't going to return the uncommitted user.

    This is entirely expected behavior.

    I'm not sure how you are trying to use parent/child contexts, but I'm
    using them in my applications to group changes until I'm ready to
    commit and it seems to work fine for me.

    Thanks,

    mrg

    On Tue, Oct 12, 2010 at 9:34 AM, Marc Guenther <yod..chli.ch> wrote:
    > Hi,
    >
    > maybe that's a stupid question, but is there a way to make a query aware of newly inserted objects?
    >
    > I have a DataContext. I insert some object into it (a user), and then, without committing the context to the DB, I query it for all users. The newly inserted user does not show up.
    >
    > The query is a normal SelectQuery. I tried playing around with caching strategies and isRefreshingObjects, but it didn't work.
    >
    > Is this the expected behaviour? Is it even possible to do this?
    >
    > I tried this, because I have a process which does lots of small changes, and some of the later ones depend on former changes. At the moment I commit every change into the DB at once, but I wanted to delay that till everything is finished, and then do it in one big commit.
    >
    > So I tried to setup a parent/child context, and commit only to the parent in the child. But then I get failures later in the process cause the earlier changes are not visible to it.
    >
    > Marc
    >
    >



    This archive was generated by hypermail 2.0.0 : Tue Oct 12 2010 - 13:51:33 UTC