Re: Help upgrading 3.0.2 code to 4.2.2

"[email protected]" <[email protected]> Mon, 8 Dec 2025 11:58:01 +0100
Newsgroups gmane.comp.java.cayenne.user
Message-ID <CAAOOpAMEc9f-7LBUfV8d+TGrWHm4cfoR8hX8eY5nuXsHcdGn8Q@mail.gmail.com>
I just wanted to share a quick update on my progresses.

I am happy to report that =E2=80=93with some help from home (THANKS Andrus!=
!)=E2=80=93
I was able to compile the application using Bootique 4.0-M1, and its
matching Cayenne version, 5.0-M1.
I am not ready to share the effort yet (but I will make it public,
eventually), as I am also radically refactoring the structure of the
repository, moving from a mono-repo, to a plethora of smaller
repositories (retaining the full history, thanks to
`git-filter-repo`).
But I haven't run the application yet, though, as I am still working
on restoring the tests, before connecting it to the actual DB.

Off to leverage Cayenne multi-db model support, an DB creation (for tests).

Cheers,

Giulio Cesare

On Sat, Nov 8, 2025 at 3:11=E2=80=AFPM [email protected]
<[email protected]> wrote:
>
> One mystery solved: the issue with the SelfProperty was caused by the
> involuntary inclusion of an older version of Cayenne by Bootique.
> Now I need to find a way to import back Bootique selecting the correct
> packages, but being now aware of the issue, I hope I will not get
> bitten by it again. =F0=9F=A4=9E
>
> Giulio Cesare
>
> On Sun, Nov 2, 2025 at 9:16=E2=80=AFPM [email protected]
> <[email protected]> wrote:
> >
> > A small update; I am using Cayenne 5.0-M1, but something is going
> > wrong with the generated base classes.
> > I have this Maven plugin configured to generate the base classes:
> >             <plugin>
> >                 <groupId>org.apache.cayenne.plugins</groupId>
> >                 <artifactId>cayenne-maven-plugin</artifactId>
> >                 <version>5.0-M1</version>
> >
> > Base classes are generated, but they all fail to compile with two
> > types of errors:
> > - this line of code
> >      public static final SelfProperty<Attachment> SELF =3D
> > PropertyFactory.createSelf(Attachment.class);
> >   fails with the error:
> >     incompatible types: no instance(s) of type variable(s) T exist so
> > that org.apache.cayenne.exp.property.EntityProperty<T> conforms to
> > org.apache.cayenne.exp.property.SelfProperty<com.clipperz.dataModel.Att=
achment>
> >
> > - all properties implementation fail using either the
> > `beforePropertyRead`, `beforePropertyWrite`, `addToManyTarget`,
> > `removeToManyTarget`, =E2=80=A6
> >
> > The model, opened with the matching version of Cayenne Modeler, does
> > not report any issues.
> >
> > What am I missing?
> > Not sure if this is relevant, but as I am already on the leading edge,
> > I am also compiling everything with Java 25.
> >
> > Thanks,
> > Giulio Cesare
> >
> >
> > On Tue, Oct 28, 2025 at 5:01=E2=80=AFAM Ricardo Parada <[email protected]=
.invalid> wrote:
> > >
> > > Hi Giulio,
> > >
> > > I=E2=80=99m interested to see how it goes. Please report back if you =
can.
> > >
> > > I=E2=80=99ve been playing with 5.0-M1.
> > >
> > >
> > > Thank you
> > > Ricardo Parada
> > >
> > >
> > >
> > > > On Oct 26, 2025, at 3:22=E2=80=AFPM, [email protected] wrote:
> > > >
> > > > =EF=BB=BFI just got back to my project, trying to finalize the upgr=
ade, 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
> > > >
> > > > Giulio Cesare
> > > >
> > > >> On Sat, Oct 4, 2025 at 10:29=E2=80=AFAM [email protected]
> > > >> <[email protected]> wrote:
> > > >>
> > > >> Thanks Michael,
> > > >> I now need to find how to rewire what I was previously doing mostl=
y
> > > >> 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).
> > > >>
> > > >> Thanks for the pointer.
> > > >>
> > > >> Giulio Cesare
> > > >>
> > > >>> On Wed, Oct 1, 2025 at 9:16=E2=80=AFPM Michael Gentry <blacknext@=
gmail.com> wrote:
> > > >>>
> > > >>> Hi Giulio,
> > > >>>
> > > >>> In 4.2, you get the ObjectContext from the Cayenne Runtime:
> > > >>>
> > > >>> https://cayenne.apache.org/docs/4.2/getting-started-guide/#gettin=
g-started-with-objectcontext
> > > >>>
> > > >>> mrg
> > > >>>
> > > >>> On Wed, Oct 1, 2025 at 5:23=E2=80=AFAM [email protected] <
> > > >>> [email protected]> wrote:
> > > >>>
> > > >>>> 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 t=
his
> > > >>>> 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.initializeSharedConfig=
uration?
> > > >>>>
> > > >>>> Thanks,
> > > >>>> Giulio Cesare
> > > >>>>
> > > >>>> On Tue, Sep 30, 2025 at 3:50=E2=80=AFPM [email protected]
> > > >>>> <[email protected]> wrote:
> > > >>>>>
> > > >>>>> Thanks Andrus!
> > > >>>>>
> > > >>>>> I'll report on any progress with my upgrade.
> > > >>>>>
> > > >>>>> Giulio Cesare
> > > >>>>>
> > > >>>>> On Tue, Sep 30, 2025 at 2:26=E2=80=AFPM Andrus Adamchik <aadamc=
[email protected]>
> > > >>>> wrote:
> > > >>>>>>
> > > >>>>>> Hi Giulio,
> > > >>>>>>
> > > >>>>>> 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-mappedexec
> > > >>>>>>
> > > >>>>>> MappedSelect.query("attachment", Attachment.class)
> > > >>>>>>    .param("reference", aReference)
> > > >>>>>>    .param("user", anUser)
> > > >>>>>>    .select(context);
> > > >>>>>>
> > > >>>>>> Thanks,
> > > >>>>>> Andrus
> > > >>>>>>
> > > >>>>>>
> > > >>>>>>> On Sep 30, 2025, at 3:15=E2=80=AFAM, [email protected] =
wrote:
> > > >>>>>>>
> > > >>>>>>> Hello everybody,
> > > >>>>>>>
> > > >>>>>>> even if this will force me to admit how old I am, I still hav=
e some
> > > >>>>>>> Cayenne 3.0.2 code happily running in production with no issu=
es.
> > > >>>>>>>
> > > >>>>>>> Lately I was trying to upgrade the application from a WAR (ru=
nning in
> > > >>>>>>> Tomcat) to a standalone application exposing the servlets via=
 Jetty,
> > > >>>>>>> in order to make the application easier to deploy in a docker
> > > >>>>>>> container.
> > > >>>>>>>
> > > >>>>>>> After some struggle to update the model, I am now facing a LO=
T of
> > > >>>>>>> deprecation warnings like this:
> > > >>>>>>>> [deprecation] SelectQuery in org.apache.cayenne.query has be=
en
> > > >>>> deprecated
> > > >>>>>>>
> > > >>>>>>> The code I have looks like this:
> > > >>>>>>> -------------------
> > > >>>>>>> prototypeQuery =3D
> > > >>>>>>>
> > > >>>> (SelectQuery)dataContext.getEntityResolver().lookupQuery("attach=
ment");
> > > >>>>>>>
> > > >>>>>>> parameters =3D new HashMap();
> > > >>>>>>> parameters.put("reference", aReference);
> > > >>>>>>> parameters.put("user", anUser);
> > > >>>>>>> query =3D prototypeQuery.queryWithParameters(parameters);
> > > >>>>>>>
> > > >>>>>>> result =3D (List<Attachment>)dataContext.performQuery(query);
> > > >>>>>>> -------------------
> > > >>>>>>>
> > > >>>>>>> Unfortunately I never had the opportunity to use any newer ve=
rsion of
> > > >>>>>>> Cayenne, so I haven't followed along with all the changes tha=
t it has
> > > >>>>>>> gone through.
> > > >>>>>>>
> > > >>>>>>> Is there anyone willing to suggest me what the above code sni=
ppet
> > > >>>>>>> would look like with the new version of Cayenne?
> > > >>>>>>>
> > > >>>>>>> Thanks,
> > > >>>>>>>
> > > >>>>>>> Giulio Cesare
> > > >>>>>>
> > > >>>>