You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2026/09/13 19:10:42 UTC
(cayenne) branch master updated: Query hierarchy cleanup
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git
The following commit(s) were added to refs/heads/master by this push:
new 59bb62189 Query hierarchy cleanup
59bb62189 is described below
commit 59bb621892965e27a700bbc00b7591f0f3ffe0ad
Author: Andrus Adamchik <an...@objectstyle.com>
AuthorDate: Sun Sep 13 15:09:32 2026 -0400
Query hierarchy cleanup
CacheableQuery superclass is gone
---
.../org/apache/cayenne/query/CacheableQuery.java | 122 ---------------------
.../java/org/apache/cayenne/query/EJBQLQuery.java | 71 +++++++++++-
.../org/apache/cayenne/query/ProcedureQuery.java | 71 +++++++++++-
.../java/org/apache/cayenne/query/SQLTemplate.java | 71 +++++++++++-
4 files changed, 201 insertions(+), 134 deletions(-)
diff --git a/cayenne/src/main/java/org/apache/cayenne/query/CacheableQuery.java b/cayenne/src/main/java/org/apache/cayenne/query/CacheableQuery.java
deleted file mode 100644
index b2fd54b1a..000000000
--- a/cayenne/src/main/java/org/apache/cayenne/query/CacheableQuery.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ****************************************************************/
-
-package org.apache.cayenne.query;
-
-/**
- * Shared functionality for cacheable queries.
- *
- * @since 4.0
- */
-public abstract class CacheableQuery implements Query {
-
- abstract protected BaseQueryMetadata getBaseMetaData();
-
- /**
- * @since 3.0
- */
- public QueryCacheStrategy getCacheStrategy() {
- return getBaseMetaData().getCacheStrategy();
- }
-
- /**
- * @since 3.0
- */
- public void setCacheStrategy(QueryCacheStrategy strategy) {
- getBaseMetaData().setCacheStrategy(strategy);
- }
-
- /**
- * @since 4.0
- */
- public String getCacheGroup() {
- return getBaseMetaData().getCacheGroup();
- }
-
- /**
- * @since 4.0
- */
- public void setCacheGroup(String cacheGroup) {
- getBaseMetaData().setCacheGroup(cacheGroup);
- }
-
-
- /**
- * Instructs Cayenne to look for query results in the "local" cache when
- * running the query. This is a short-hand notation for:
- *
- * <pre>
- * query.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
- * </pre>
- *
- * @since 4.0
- */
- public void useLocalCache() {
- setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
- }
-
- /**
- * Instructs Cayenne to look for query results in the "local" cache when
- * running the query. This is a short-hand notation for:
- *
- * <pre>
- * query.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
- * query.setCacheGroups("group1", "group2");
- * </pre>
- *
- * @since 4.0
- */
- public void useLocalCache(String cacheGroup) {
- setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
- setCacheGroup(cacheGroup);
- }
-
-
-
- /**
- * Instructs Cayenne to look for query results in the "shared" cache when
- * running the query. This is a short-hand notation for:
- *
- * <pre>
- * query.setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
- * </pre>
- *
- * @since 4.0
- */
- public void useSharedCache() {
- setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
- }
-
- /**
- * Instructs Cayenne to look for query results in the "shared" cache when
- * running the query. This is a short-hand notation for:
- *
- * <pre>
- * query.setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
- * query.setCacheGroups("group1", "group2");
- * </pre>
- *
- * @since 4.0
- */
- public void useSharedCache(String cacheGroup) {
- setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
- setCacheGroup(cacheGroup);
- }
-
-}
diff --git a/cayenne/src/main/java/org/apache/cayenne/query/EJBQLQuery.java b/cayenne/src/main/java/org/apache/cayenne/query/EJBQLQuery.java
index d5fc4a117..09c8a763e 100644
--- a/cayenne/src/main/java/org/apache/cayenne/query/EJBQLQuery.java
+++ b/cayenne/src/main/java/org/apache/cayenne/query/EJBQLQuery.java
@@ -36,7 +36,7 @@ import org.apache.cayenne.map.EntityResolver;
* the query is fetching data rows.
* @since 3.0
*/
-public class EJBQLQuery<T> extends CacheableQuery implements Select<T> {
+public class EJBQLQuery<T> implements Select<T> {
protected String ejbqlStatement;
@@ -66,9 +66,72 @@ public class EJBQLQuery<T> extends CacheableQuery implements Select<T> {
metadata.setFetchingDataRows(flag);
}
- @Override
- protected BaseQueryMetadata getBaseMetaData() {
- return metadata;
+ /**
+ * @since 3.0
+ */
+ public QueryCacheStrategy getCacheStrategy() {
+ return metadata.getCacheStrategy();
+ }
+
+ /**
+ * @since 3.0
+ */
+ public void setCacheStrategy(QueryCacheStrategy strategy) {
+ metadata.setCacheStrategy(strategy);
+ }
+
+ /**
+ * @since 4.0
+ */
+ public String getCacheGroup() {
+ return metadata.getCacheGroup();
+ }
+
+ /**
+ * @since 4.0
+ */
+ public void setCacheGroup(String cacheGroup) {
+ metadata.setCacheGroup(cacheGroup);
+ }
+
+ /**
+ * @since 4.0
+ * @deprecated use {@link #setCacheStrategy(QueryCacheStrategy)} with {@link QueryCacheStrategy#LOCAL_CACHE}
+ */
+ @Deprecated(since = "5.0", forRemoval = true)
+ public void useLocalCache() {
+ setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
+ }
+
+ /**
+ * @since 4.0
+ * @deprecated use {@link #setCacheStrategy(QueryCacheStrategy)} with {@link QueryCacheStrategy#LOCAL_CACHE} and
+ * {@link #setCacheGroup(String)}
+ */
+ @Deprecated(since = "5.0", forRemoval = true)
+ public void useLocalCache(String cacheGroup) {
+ setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
+ setCacheGroup(cacheGroup);
+ }
+
+ /**
+ * @since 4.0
+ * @deprecated use {@link #setCacheStrategy(QueryCacheStrategy)} with {@link QueryCacheStrategy#SHARED_CACHE}
+ */
+ @Deprecated(since = "5.0", forRemoval = true)
+ public void useSharedCache() {
+ setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
+ }
+
+ /**
+ * @since 4.0
+ * @deprecated use {@link #setCacheStrategy(QueryCacheStrategy)} with {@link QueryCacheStrategy#SHARED_CACHE} and
+ * {@link #setCacheGroup(String)}
+ */
+ @Deprecated(since = "5.0", forRemoval = true)
+ public void useSharedCache(String cacheGroup) {
+ setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
+ setCacheGroup(cacheGroup);
}
public SQLAction createSQLAction(SQLActionVisitor visitor) {
diff --git a/cayenne/src/main/java/org/apache/cayenne/query/ProcedureQuery.java b/cayenne/src/main/java/org/apache/cayenne/query/ProcedureQuery.java
index 810deed85..5b191de98 100644
--- a/cayenne/src/main/java/org/apache/cayenne/query/ProcedureQuery.java
+++ b/cayenne/src/main/java/org/apache/cayenne/query/ProcedureQuery.java
@@ -57,7 +57,7 @@ import java.util.Map;
* @param <T> the type of the result elements: a {@link org.apache.cayenne.DataRow} by default, or a persistent
* object when a result type is specified.
*/
-public class ProcedureQuery<T> extends CacheableQuery implements Select<T> {
+public class ProcedureQuery<T> implements Select<T> {
protected String resultEntityName;
protected Class<?> resultClass;
@@ -243,9 +243,72 @@ public class ProcedureQuery<T> extends CacheableQuery implements Select<T> {
return context.selectFirst(this);
}
- @Override
- protected BaseQueryMetadata getBaseMetaData() {
- return metaData;
+ /**
+ * @since 3.0
+ */
+ public QueryCacheStrategy getCacheStrategy() {
+ return metaData.getCacheStrategy();
+ }
+
+ /**
+ * @since 3.0
+ */
+ public void setCacheStrategy(QueryCacheStrategy strategy) {
+ metaData.setCacheStrategy(strategy);
+ }
+
+ /**
+ * @since 4.0
+ */
+ public String getCacheGroup() {
+ return metaData.getCacheGroup();
+ }
+
+ /**
+ * @since 4.0
+ */
+ public void setCacheGroup(String cacheGroup) {
+ metaData.setCacheGroup(cacheGroup);
+ }
+
+ /**
+ * @since 4.0
+ * @deprecated use {@link #setCacheStrategy(QueryCacheStrategy)} with {@link QueryCacheStrategy#LOCAL_CACHE}
+ */
+ @Deprecated(since = "5.0", forRemoval = true)
+ public void useLocalCache() {
+ setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
+ }
+
+ /**
+ * @since 4.0
+ * @deprecated use {@link #setCacheStrategy(QueryCacheStrategy)} with {@link QueryCacheStrategy#LOCAL_CACHE} and
+ * {@link #setCacheGroup(String)}
+ */
+ @Deprecated(since = "5.0", forRemoval = true)
+ public void useLocalCache(String cacheGroup) {
+ setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
+ setCacheGroup(cacheGroup);
+ }
+
+ /**
+ * @since 4.0
+ * @deprecated use {@link #setCacheStrategy(QueryCacheStrategy)} with {@link QueryCacheStrategy#SHARED_CACHE}
+ */
+ @Deprecated(since = "5.0", forRemoval = true)
+ public void useSharedCache() {
+ setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
+ }
+
+ /**
+ * @since 4.0
+ * @deprecated use {@link #setCacheStrategy(QueryCacheStrategy)} with {@link QueryCacheStrategy#SHARED_CACHE} and
+ * {@link #setCacheGroup(String)}
+ */
+ @Deprecated(since = "5.0", forRemoval = true)
+ public void useSharedCache(String cacheGroup) {
+ setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
+ setCacheGroup(cacheGroup);
}
public int getFetchLimit() {
diff --git a/cayenne/src/main/java/org/apache/cayenne/query/SQLTemplate.java b/cayenne/src/main/java/org/apache/cayenne/query/SQLTemplate.java
index 2ae095919..f74336c17 100644
--- a/cayenne/src/main/java/org/apache/cayenne/query/SQLTemplate.java
+++ b/cayenne/src/main/java/org/apache/cayenne/query/SQLTemplate.java
@@ -70,7 +70,7 @@ import java.util.stream.Stream;
* persistent object, a {@link org.apache.cayenne.DataRow}, a scalar or an {@code Object[]}.
* @since 1.1
*/
-public class SQLTemplate<T> extends CacheableQuery implements Select<T> {
+public class SQLTemplate<T> implements Select<T> {
private static final Function<Map<String, ?>, Map<String, ?>> nullMapTransformer = input ->
(input != null) ? input : Collections.emptyMap();
@@ -335,9 +335,72 @@ public class SQLTemplate<T> extends CacheableQuery implements Select<T> {
return query;
}
- @Override
- protected BaseQueryMetadata getBaseMetaData() {
- return metaData;
+ /**
+ * @since 3.0
+ */
+ public QueryCacheStrategy getCacheStrategy() {
+ return metaData.getCacheStrategy();
+ }
+
+ /**
+ * @since 3.0
+ */
+ public void setCacheStrategy(QueryCacheStrategy strategy) {
+ metaData.setCacheStrategy(strategy);
+ }
+
+ /**
+ * @since 4.0
+ */
+ public String getCacheGroup() {
+ return metaData.getCacheGroup();
+ }
+
+ /**
+ * @since 4.0
+ */
+ public void setCacheGroup(String cacheGroup) {
+ metaData.setCacheGroup(cacheGroup);
+ }
+
+ /**
+ * @since 4.0
+ * @deprecated use {@link #setCacheStrategy(QueryCacheStrategy)} with {@link QueryCacheStrategy#LOCAL_CACHE}
+ */
+ @Deprecated(since = "5.0", forRemoval = true)
+ public void useLocalCache() {
+ setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
+ }
+
+ /**
+ * @since 4.0
+ * @deprecated use {@link #setCacheStrategy(QueryCacheStrategy)} with {@link QueryCacheStrategy#LOCAL_CACHE} and
+ * {@link #setCacheGroup(String)}
+ */
+ @Deprecated(since = "5.0", forRemoval = true)
+ public void useLocalCache(String cacheGroup) {
+ setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
+ setCacheGroup(cacheGroup);
+ }
+
+ /**
+ * @since 4.0
+ * @deprecated use {@link #setCacheStrategy(QueryCacheStrategy)} with {@link QueryCacheStrategy#SHARED_CACHE}
+ */
+ @Deprecated(since = "5.0", forRemoval = true)
+ public void useSharedCache() {
+ setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
+ }
+
+ /**
+ * @since 4.0
+ * @deprecated use {@link #setCacheStrategy(QueryCacheStrategy)} with {@link QueryCacheStrategy#SHARED_CACHE} and
+ * {@link #setCacheGroup(String)}
+ */
+ @Deprecated(since = "5.0", forRemoval = true)
+ public void useSharedCache(String cacheGroup) {
+ setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
+ setCacheGroup(cacheGroup);
}
public int getFetchLimit() {