Hi Rob, Actually, "no cache" is the default strategy for every query. What may remain cached after a query is related objects. So while you do not need an explicit "cacheStrategy(QueryCacheStrategy.NO_CACHE)", you may need to curate your prefetches to ensure the relevant subgraph is refreshed.
Andrus > On Apr 20, 2026, at 11:15 AM, Robert A. Decker <[email protected]> wrote: > > Is it as simple as: > > List<AiJob> jobs = 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: >> >> 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 = cayenne.newContext(); (cayenne is a ServerRuntime >> built like at the end of this message) >> >> 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? >> >> thanks, >> Rob >> >> >> >> cayenneRuntime = 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.username")) >> >> .password(environment.getProperty("org.apache.cayenne.datasource.jdbc.password")) >> >> .pool(Integer.parseInt(Objects.requireNonNull(environment.getProperty("org.apache.cayenne.datasource.jdbc.minConnections"))), >> >> Integer.parseInt(Objects.requireNonNull(environment.getProperty("org.apache.cayenne.datasource.jdbc.maxConnections")))) >> .build()) >> .build(); >> >
