Re: cached objects in the object context?

"Robert A. Decker" <[email protected]> Mon, 20 Apr 2026 17:15:42 +0200
Newsgroups gmane.comp.java.cayenne.user
Message-ID <[email protected]>
Is it as simple as:

List<AiJob> jobs =3D ObjectSelect.query(AiJob.class)
.cacheStrategy(QueryCacheStrategy.NO_CACHE)
.where(...

I just want the entire graph of the fetch to be fresh each time.

Rob


> On 20 Apr 2026, at 13:49, Robert A. Decker <[email protected]> =
wrote:
>=20
> I have a couple of different systems modifying the database my cayenne =
code is talking to. Every now and then I see behaviour that I think says =
that something is being cached between database searches even though I =
create a new context before each search:
> ObjectContext context =3D cayenne.newContext();   (cayenne is a =
ServerRuntime built like at the end of this message)
>=20
> Even though I'm creating a new context before the search, could the =
server runtime that the context is built from be caching objects? If so, =
should I wipe the cache before the search? Or is there a way to make =
sure it doesn't work with a cache?
>=20
> thanks,
> Rob
>=20
>=20
>=20
>        cayenneRuntime =3D ServerRuntime.builder()
>                .addConfig("cayenne-project.xml")
>                .addModule(binder ->
>                        ServerModule.contributePkGenerators(binder)
>                                .put(MySQLAdapter.class.getName(), =
SmsPkGenerator.class))
>                .dataSource(DataSourceBuilder
>                        =
.url(environment.getProperty("org.apache.cayenne.datasource.jdbc.url"))
>                        =
.driver(environment.getProperty("org.apache.cayenne.datasource.jdbc.driver=
"))
>                        =
.userName(environment.getProperty("org.apache.cayenne.datasource.jdbc.user=
name"))
>                        =
.password(environment.getProperty("org.apache.cayenne.datasource.jdbc.pass=
word"))
>                        =
.pool(Integer.parseInt(Objects.requireNonNull(environment.getProperty("org=
.apache.cayenne.datasource.jdbc.minConnections"))),
>                              =
Integer.parseInt(Objects.requireNonNull(environment.getProperty("org.apach=
e.cayenne.datasource.jdbc.maxConnections"))))
>                        .build())
>                .build();
>=20