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?

Thanks,
Giulio Cesare

On Tue, Sep 30, 2025 at 3:50 PM [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 PM Andrus Adamchik <[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 AM, [email protected] wrote:
> > >
> > > Hello everybody,
> > >
> > > 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.
> > >
> > > 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.
> > >
> > > 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
> > >
> > > The code I have looks like this:
> > > -------------------
> > > prototypeQuery =
> > > (SelectQuery)dataContext.getEntityResolver().lookupQuery("attachment");
> > >
> > > parameters = new HashMap();
> > > parameters.put("reference", aReference);
> > > parameters.put("user", anUser);
> > > query = prototypeQuery.queryWithParameters(parameters);
> > >
> > > result = (List<Attachment>)dataContext.performQuery(query);
> > > -------------------
> > >
> > > 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.
> > >
> > > Is there anyone willing to suggest me what the above code snippet
> > > would look like with the new version of Cayenne?
> > >
> > > Thanks,
> > >
> > > Giulio Cesare
> >

Reply via email to