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