Re: DataContext.performNonSelectingQuery()

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Mon Sep 05 2005 - 15:37:58 EDT

  • Next message: Cris Daniluk: "Re: DataContext.invalidateObject(DataObject)"

    On Sep 5, 2005, at 2:23 PM, Gili wrote:

    > So if I wanted to synchronize Cayenne state after using a
    > SQLTemplate I'd have to invoke context.commitChanges() followed by
    > context.invalidateObjects(dataContext.getObjectStore().getObjects
    > ())? Ideally I shouldn't have to commit the transaction yet.

    SQLTemplate does its own commit. So "context.commitChanges()" has
    nothing to do with SQLTemplate execution. Like we discussed before,
    if you want a special transaction demarcation (i.e. execute multiple
    DB interactions within an open transaction), you will need to use
    external transactions.

    I never had to do that in my practice, so maybe there is still some
    Hibernate mindset present in your design that makes it necessary.
    E.g. if instead of building a SQLTemplate to delete your objects, you
    delete them via DataContext (fetch, then analyze in memory, then
    delete a subset of them), you won't have to go through all that.

    > Is there a way for me to tell Cayenne "for all objects in the
    > ObjectStore, merge the memory state with the DB state"?

    Umm, yeah - context.invalidateObjects(dataContext.getObjectStore
    ().getObjects())

    Andrus



    This archive was generated by hypermail 2.0.0 : Mon Sep 05 2005 - 15:38:00 EDT