Re: Help upgrading 3.0.2 code to 4.2.2
Andrus Adamchik <[email protected]> Tue, 30 Sep 2025 08:02:53 -0400
| Newsgroups | gmane.comp.java.cayenne.user |
|---|---|
| Message-ID | <[email protected]> |
--Apple-Mail=_2EE27DCB-23EF-4865-AE21-BE8A7C247F1C
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=utf-8
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-mapped=
exec=20
MappedSelect.query("attachment", Attachment.class)=E2=80=A8
.param("reference", aReference)=E2=80=A8
.param("user", anUser)=E2=80=A8
.select(context);
Thanks,
Andrus
> 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
> =
(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
--Apple-Mail=_2EE27DCB-23EF-4865-AE21-BE8A7C247F1C--