Re: Help upgrading 3.0.2 code to 4.2.2
Andrus Adamchik <[email protected]> Sun, 26 Oct 2025 15:57:37 -0700
| Newsgroups | gmane.comp.java.cayenne.user |
|---|---|
| Message-ID | <[email protected]> |
Good luck! Straight to the future :)=20 > On Oct 26, 2025, at 12:21=E2=80=AFPM, [email protected] wrote: >=20 > I just got back to my project, trying to finalize the upgrade, and I > find out there is a brand new version of Cayenne available. > I am going to try to jump directly from 3.0.2 to 5.0-M1. =F0=9F=8E=A2 > Wish me luck! =F0=9F=A4=B9 >=20 > Giulio Cesare >=20 > On Sat, Oct 4, 2025 at 10:29=E2=80=AFAM [email protected] > <[email protected]> wrote: >>=20 >> Thanks Michael, >> I now need to find how to rewire what I was previously doing mostly >> using the org.apache.cayenne.conf package. >> I suppose this is part of the friction I'll have to go through to get >> a plain Jar (with Jetty). >>=20 >> Thanks for the pointer. >>=20 >> Giulio Cesare >>=20 >> On Wed, Oct 1, 2025 at 9:16=E2=80=AFPM Michael Gentry = <[email protected]> wrote: >>>=20 >>> Hi Giulio, >>>=20 >>> In 4.2, you get the ObjectContext from the Cayenne Runtime: >>>=20 >>> = https://cayenne.apache.org/docs/4.2/getting-started-guide/#getting-started= -with-objectcontext >>>=20 >>> mrg >>>=20 >>> On Wed, Oct 1, 2025 at 5:23=E2=80=AFAM [email protected] < >>> [email protected]> wrote: >>>=20 >>>> Hello, >>>> I have been able to fix almost all the warnings and errors. >>>> I have to points that I am not able to fix, though: >>>> - I was still using DataContext (instead of ObjectContext); is this >>>> still a useful class? Otherwise, how do I create a DataContext, as >>>> `DataContext.createDataContext();` is not defined >>>> - how do I replace the use of = ServletUtil.initializeSharedConfiguration? >>>>=20 >>>> Thanks, >>>> Giulio Cesare >>>>=20 >>>> On Tue, Sep 30, 2025 at 3:50=E2=80=AFPM [email protected] >>>> <[email protected]> wrote: >>>>>=20 >>>>> Thanks Andrus! >>>>>=20 >>>>> I'll report on any progress with my upgrade. >>>>>=20 >>>>> Giulio Cesare >>>>>=20 >>>>> On Tue, Sep 30, 2025 at 2:26=E2=80=AFPM Andrus Adamchik = <[email protected]> >>>> wrote: >>>>>>=20 >>>>>> Hi Giulio, >>>>>>=20 >>>>>> SelectQuery is replaced with ObjectSelect. But in your case (a = query >>>> modeled in the DataMap), you would actually use something else - a >>>> MappedSelect query per >>>> = https://cayenne.apache.org/docs/4.2/cayenne-guide/#mappedselect-and-mapped= exec >>>>>>=20 >>>>>> MappedSelect.query("attachment", Attachment.class) >>>>>> .param("reference", aReference) >>>>>> .param("user", anUser) >>>>>> .select(context); >>>>>>=20 >>>>>> Thanks, >>>>>> Andrus >>>>>>=20 >>>>>>=20 >>>>>>> On Sep 30, 2025, at 3:15=E2=80=AFAM, [email protected] = wrote: >>>>>>>=20 >>>>>>> Hello everybody, >>>>>>>=20 >>>>>>> even if this will force me to admit how old I am, I still have = some >>>>>>> Cayenne 3.0.2 code happily running in production with no issues. >>>>>>>=20 >>>>>>> Lately I was trying to upgrade the application from a WAR = (running in >>>>>>> Tomcat) to a standalone application exposing the servlets via = Jetty, >>>>>>> in order to make the application easier to deploy in a docker >>>>>>> container. >>>>>>>=20 >>>>>>> After some struggle to update the model, I am now facing a LOT = of >>>>>>> deprecation warnings like this: >>>>>>>> [deprecation] SelectQuery in org.apache.cayenne.query has been >>>> deprecated >>>>>>>=20 >>>>>>> The code I have looks like this: >>>>>>> ------------------- >>>>>>> prototypeQuery =3D >>>>>>>=20 >>>> = (SelectQuery)dataContext.getEntityResolver().lookupQuery("attachment"); >>>>>>>=20 >>>>>>> parameters =3D new HashMap(); >>>>>>> parameters.put("reference", aReference); >>>>>>> parameters.put("user", anUser); >>>>>>> query =3D prototypeQuery.queryWithParameters(parameters); >>>>>>>=20 >>>>>>> result =3D (List<Attachment>)dataContext.performQuery(query); >>>>>>> ------------------- >>>>>>>=20 >>>>>>> Unfortunately I never had the opportunity to use any newer = version of >>>>>>> Cayenne, so I haven't followed along with all the changes that = it has >>>>>>> gone through. >>>>>>>=20 >>>>>>> Is there anyone willing to suggest me what the above code = snippet >>>>>>> would look like with the new version of Cayenne? >>>>>>>=20 >>>>>>> Thanks, >>>>>>>=20 >>>>>>> Giulio Cesare >>>>>>=20 >>>>=20