FAQ
Hi,


I have been trying to upgrade Cayenne from v3.0 to v3.1. I have read the
changes in Upgrade.txt bundled with the modeler download.

I have used DataContext pretty extensively. In fact, I have a singleton for
creating DataContext. Now, with new changes, it seems to me that DataContext
has been eliminated and advised to use ObjectContext using
ServerRuntime.getContext(...) instead. So, now I have thousands of places
where I have done MySingleton.getDataContext().commitChanges() needed to be
changed. (which I will do)

I wanted to confirm that going forward, I will need to replace

DataContext.createDataContext()

with

ServerRuntime cayenneRuntime = new
ServerRuntime("cayenne-edushare.xml");
cayenneRuntime.getContext()

Or, am I missing something?

Thanks
Nishant

Search Discussions

  • Andrus Adamchik at Feb 13, 2011 at 8:55 am
    DataContext is an implementation of ObjectContext, so returned ObjectContext is really a DataContext. Not much change here. So if you can, use ObjectContext API in an abstract way, but if you absolutely have to reference DataContext explicitly, use a cast:

    DataContext context = (DataContext) cayenneRuntime.getContext();

    Andrus

    On Feb 12, 2011, at 2:45 PM, Nishant Neeraj wrote:
    Hi,


    I have been trying to upgrade Cayenne from v3.0 to v3.1. I have read the
    changes in Upgrade.txt bundled with the modeler download.

    I have used DataContext pretty extensively. In fact, I have a singleton for
    creating DataContext. Now, with new changes, it seems to me that DataContext
    has been eliminated and advised to use ObjectContext using
    ServerRuntime.getContext(...) instead. So, now I have thousands of places
    where I have done MySingleton.getDataContext().commitChanges() needed to be
    changed. (which I will do)

    I wanted to confirm that going forward, I will need to replace

    DataContext.createDataContext()

    with

    ServerRuntime cayenneRuntime = new
    ServerRuntime("cayenne-edushare.xml");
    cayenneRuntime.getContext()

    Or, am I missing something?

    Thanks
    Nishant
  • Andrus Adamchik at Feb 13, 2011 at 9:05 am
    And of course a common disclaimer: 3.1 is still Alpha, and while it is great that people try it (we encourage early adopters; fwiw I am also running 3.1 in production), but be prepared for the new API to change as it evolves.

    Andrus
    On Feb 13, 2011, at 10:54 AM, Andrus Adamchik wrote:

    DataContext is an implementation of ObjectContext, so returned ObjectContext is really a DataContext. Not much change here. So if you can, use ObjectContext API in an abstract way, but if you absolutely have to reference DataContext explicitly, use a cast:

    DataContext context = (DataContext) cayenneRuntime.getContext();

    Andrus

    On Feb 12, 2011, at 2:45 PM, Nishant Neeraj wrote:
    Hi,


    I have been trying to upgrade Cayenne from v3.0 to v3.1. I have read the
    changes in Upgrade.txt bundled with the modeler download.

    I have used DataContext pretty extensively. In fact, I have a singleton for
    creating DataContext. Now, with new changes, it seems to me that DataContext
    has been eliminated and advised to use ObjectContext using
    ServerRuntime.getContext(...) instead. So, now I have thousands of places
    where I have done MySingleton.getDataContext().commitChanges() needed to be
    changed. (which I will do)

    I wanted to confirm that going forward, I will need to replace

    DataContext.createDataContext()

    with

    ServerRuntime cayenneRuntime = new
    ServerRuntime("cayenne-edushare.xml");
    cayenneRuntime.getContext()

    Or, am I missing something?

    Thanks
    Nishant

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriescayenne
postedFeb 12, '11 at 12:45p
activeFeb 13, '11 at 9:05a
posts3
users2
websitecayenne.apache.org

2 users in discussion

Andrus Adamchik: 2 posts Nishant Neeraj: 1 post

People

Translate

site design / logo © 2022 Grokbase