You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Nishant Neeraj <ni...@gmail.com> on 2011/02/12 13:45:09 UTC
Upgrading 3.0 to 3.1
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
Re: Upgrading 3.0 to 3.1
Posted by Andrus Adamchik <an...@objectstyle.org>.
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
>
>
Re: Upgrading 3.0 to 3.1
Posted by Andrus Adamchik <an...@objectstyle.org>.
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