This is an automated email from the ASF dual-hosted git repository. ntimofeev pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/cayenne.git
commit 336f0e5297fe6ccdc3b1904ab4f6ee2c6d1ab9dc Author: Nikita Timofeev <stari...@gmail.com> AuthorDate: Thu Jun 30 18:03:11 2022 +0300 CAY-2737 Cayenne 4.3: cleanup deprecated code --- .../cache/invalidation/InvalidationFunction.java | 39 -------- .../configuration/rop/server/ROPServerModule.java | 14 --- .../java/org/apache/cayenne/CayenneDataObject.java | 14 --- .../java/org/apache/cayenne/CayenneException.java | 82 ---------------- .../apache/cayenne/CayenneRuntimeException.java | 2 +- .../apache/cayenne/access/OperationObserver.java | 11 --- .../cayenne/dba/sqlserver/SQLServerAdapter.java | 6 -- .../apache/cayenne/map/SelectQueryDescriptor.java | 32 ------ .../java/org/apache/cayenne/query/SQLSelect.java | 84 ---------------- .../cayenne/tx/DefaultTransactionDescriptor.java | 9 +- .../apache/cayenne/tx/TransactionDescriptor.java | 45 +-------- .../org/apache/cayenne/CayenneExceptionTest.java | 75 -------------- .../org/apache/cayenne/access/DbArcIdTest.java | 74 -------------- .../apache/cayenne/access/FlattenedArcKeyIT.java | 98 ------------------- .../java/org/apache/cayenne/query/SQLSelectIT.java | 2 +- .../velocity/SQLTemplateResourceManager.java | 108 --------------------- .../apache/cayenne/wocompat/EOModelProcessor.java | 3 +- .../java/org/apache/cayenne/wocompat/EOQuery.java | 8 -- 18 files changed, 10 insertions(+), 696 deletions(-) diff --git a/cayenne-cache-invalidation/src/main/java/org/apache/cayenne/cache/invalidation/InvalidationFunction.java b/cayenne-cache-invalidation/src/main/java/org/apache/cayenne/cache/invalidation/InvalidationFunction.java deleted file mode 100644 index 59a8a2749..000000000 --- a/cayenne-cache-invalidation/src/main/java/org/apache/cayenne/cache/invalidation/InvalidationFunction.java +++ /dev/null @@ -1,39 +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.cache.invalidation; - -import org.apache.cayenne.Persistent; - -import java.util.Collection; -import java.util.function.Function; - -/** - * @since 4.0 - * @deprecated since 4.1 plain Function>Persistent, Collection>CacheGroupDescriptor>> can be used. - */ -@Deprecated -public interface InvalidationFunction extends Function<Persistent, Collection<CacheGroupDescriptor>> { - - /** - * @return collection of cache groups to invalidate for given object - */ - Collection<CacheGroupDescriptor> apply(Persistent persistent); - -} \ No newline at end of file diff --git a/cayenne-rop-server/src/main/java/org/apache/cayenne/configuration/rop/server/ROPServerModule.java b/cayenne-rop-server/src/main/java/org/apache/cayenne/configuration/rop/server/ROPServerModule.java index 896ff89e4..ec6a57dc5 100644 --- a/cayenne-rop-server/src/main/java/org/apache/cayenne/configuration/rop/server/ROPServerModule.java +++ b/cayenne-rop-server/src/main/java/org/apache/cayenne/configuration/rop/server/ROPServerModule.java @@ -55,20 +55,6 @@ public class ROPServerModule implements Module { return binder.bindList(String.class, ROPConstants.SERIALIZATION_WHITELIST); } - - public ROPServerModule() {} - - /** - * @deprecated since 4.2 ROPServerModule became autoloaded. - * You need to contribute eventBridgeProperties yourself. - * Use {@link #contributeROPBridgeProperties(Binder)} to - * contribute properties. - */ - @Deprecated - public ROPServerModule(Map<String, String> eventBridgeProperties) { - this.eventBridgeProperties = eventBridgeProperties; - } - public void configure(Binder binder) { contributeSerializationWhitelist(binder); MapBuilder<String> mapBuilder = contributeROPBridgeProperties(binder); diff --git a/cayenne-server/src/main/java/org/apache/cayenne/CayenneDataObject.java b/cayenne-server/src/main/java/org/apache/cayenne/CayenneDataObject.java index de20ced25..72fb66835 100644 --- a/cayenne-server/src/main/java/org/apache/cayenne/CayenneDataObject.java +++ b/cayenne-server/src/main/java/org/apache/cayenne/CayenneDataObject.java @@ -140,18 +140,4 @@ public class CayenneDataObject extends BaseDataObject { super.writeState(out); out.writeObject(values); } - - /** - * Convenience method to invoke {@link Cayenne#makePath(String...)} from - * within a DataObject subclass to create a dotted path using the generated - * string constants for attributes and relationships. - * - * @deprecated since 4.1, use {@link Cayenne#makePath(String...)} instead - * @see Cayenne#makePath(String...) - * @since 3.1 - */ - @Deprecated - public static String makePath(String... pathParts) { - return Cayenne.makePath(pathParts); - } } diff --git a/cayenne-server/src/main/java/org/apache/cayenne/CayenneException.java b/cayenne-server/src/main/java/org/apache/cayenne/CayenneException.java deleted file mode 100644 index e9ccc1d34..000000000 --- a/cayenne-server/src/main/java/org/apache/cayenne/CayenneException.java +++ /dev/null @@ -1,82 +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; - - -/** - * A generic checked exception that may be thrown by Cayenne framework. All checked - * exceptions in Cayenne inherit from this class. - * - * @deprecated since 4.1 use {@link CayenneRuntimeException} instead - */ -@Deprecated -public class CayenneException extends Exception { - - /** - * @deprecated since 4.1 use {@link CayenneRuntimeException#getExceptionLabel()} - */ - @Deprecated - public static String getExceptionLabel() { - return CayenneRuntimeException.getExceptionLabel(); - } - - /** - * Creates new <code>CayenneException</code> without detail message. - */ - public CayenneException() { - } - - /** - * Constructs an <code>CayenneException</code> with the specified detail message. - * - * @param messageFormat the detail message format string. - */ - public CayenneException(String messageFormat, Object... messageArgs) { - super(String.format(messageFormat, messageArgs)); - } - - /** - * Constructs an <code>CayenneException</code> that wraps a <code>cause</code> thrown - * elsewhere. - */ - public CayenneException(Throwable cause) { - super(cause); - } - - public CayenneException(String messageFormat, Throwable cause, Object... messageArgs) { - super(String.format(messageFormat, messageArgs), cause); - } - - /** - * Returns exception message without Cayenne version label. - * - * @since 1.1 - */ - public String getUnlabeledMessage() { - return super.getMessage(); - } - - @Override - public String getMessage() { - String message = super.getMessage(); - return (message != null) ? getExceptionLabel() + message : getExceptionLabel() - + "(no message)"; - } -} diff --git a/cayenne-server/src/main/java/org/apache/cayenne/CayenneRuntimeException.java b/cayenne-server/src/main/java/org/apache/cayenne/CayenneRuntimeException.java index c6a687285..083dd124d 100644 --- a/cayenne-server/src/main/java/org/apache/cayenne/CayenneRuntimeException.java +++ b/cayenne-server/src/main/java/org/apache/cayenne/CayenneRuntimeException.java @@ -36,7 +36,7 @@ public class CayenneRuntimeException extends RuntimeException { } /** - * @since 4.1 moved from deprecated {@link CayenneException} + * @since 4.1 */ public static String getExceptionLabel() { return exceptionLabel; diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/OperationObserver.java b/cayenne-server/src/main/java/org/apache/cayenne/access/OperationObserver.java index 955383124..721a6de11 100644 --- a/cayenne-server/src/main/java/org/apache/cayenne/access/OperationObserver.java +++ b/cayenne-server/src/main/java/org/apache/cayenne/access/OperationObserver.java @@ -58,17 +58,6 @@ public interface OperationObserver extends OperationHints { */ void nextRows(Query q, ResultIterator<?> it); - /** - * Callback method invoked after each batch of generated values is read during an update. - * - * @since 4.0 - * @deprecated since 4.2, use {@link #nextGeneratedRows(Query, ResultIterator, List)} - */ - @Deprecated - default void nextGeneratedRows(Query query, ResultIterator<?> keys, ObjectId idToUpdate) { - nextGeneratedRows(query, keys, Collections.singletonList(idToUpdate)); - } - /** * Callback method invoked after each batch of generated values is read during an update. * @since 4.2 diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerAdapter.java b/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerAdapter.java index 6642e8e5e..401fa1d63 100644 --- a/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerAdapter.java +++ b/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerAdapter.java @@ -82,12 +82,6 @@ public class SQLServerAdapter extends SybaseAdapter { */ private Integer version; - /** - * @deprecated since 4.2 unused - */ - @Deprecated - public static final String TRIM_FUNCTION = "RTRIM"; - private final List<String> SYSTEM_SCHEMAS = Arrays.asList( "db_accessadmin", "db_backupoperator", "db_datareader", "db_datawriter", "db_ddladmin", "db_denydatareader", diff --git a/cayenne-server/src/main/java/org/apache/cayenne/map/SelectQueryDescriptor.java b/cayenne-server/src/main/java/org/apache/cayenne/map/SelectQueryDescriptor.java index 8722cd0d4..ae6ac57f6 100644 --- a/cayenne-server/src/main/java/org/apache/cayenne/map/SelectQueryDescriptor.java +++ b/cayenne-server/src/main/java/org/apache/cayenne/map/SelectQueryDescriptor.java @@ -110,16 +110,6 @@ public class SelectQueryDescriptor extends QueryDescriptor { return prefetchesMap; } - /** - * Returns list of prefetch paths for this query. - * - * @deprecated since 4.1 use {@link #getPrefetchesMap()}. - */ - @Deprecated - public List<String> getPrefetches() { - return new ArrayList<>(prefetchesMap.keySet()); - } - /** * Sets map of prefetch paths with semantics for this query. * @@ -129,18 +119,6 @@ public class SelectQueryDescriptor extends QueryDescriptor { this.prefetchesMap = prefetchesMap; } - /** - * Sets list of prefetch paths for this query. - * - * @deprecated since 4.1 use {@link #setPrefetchesMap(HashMap)}. - */ - @Deprecated - public void setPrefetches(List<String> prefetches) { - for(String prefetch : prefetches){ - this.prefetchesMap.put(prefetch, PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS); - } - } - /** * Adds prefetch path with semantics to this query. * @@ -150,16 +128,6 @@ public class SelectQueryDescriptor extends QueryDescriptor { this.prefetchesMap.put(prefetchPath, semantics); } - /** - * Adds single prefetch path to this query. - * - * @deprecated since 4.1 use {@link #addPrefetch(String, int)} - */ - @Deprecated - public void addPrefetch(String prefetchPath) { - this.prefetchesMap.put(prefetchPath, PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS); - } - /** * Removes single prefetch path from this query. */ diff --git a/cayenne-server/src/main/java/org/apache/cayenne/query/SQLSelect.java b/cayenne-server/src/main/java/org/apache/cayenne/query/SQLSelect.java index 3278036fd..2e5fda6ec 100644 --- a/cayenne-server/src/main/java/org/apache/cayenne/query/SQLSelect.java +++ b/cayenne-server/src/main/java/org/apache/cayenne/query/SQLSelect.java @@ -93,27 +93,6 @@ public class SQLSelect<T> extends IndirectQuery implements Select<T> { return new SQLSelect<>(type, sql); } - /** - * Creates a query that selects scalar values and uses default routing. - * @deprecated since 4.2. Use {@link #scalarQuery(String, Class)} method. - */ - @Deprecated - public static <T> SQLSelect<T> scalarQuery(Class<T> type, String sql) { - return scalarQuery(sql, type); - } - - /** - * Creates a query that selects scalar values and uses routing based on the - * provided DataMap name. - * @deprecated since 4.2. Use {@link #scalarQuery(String, String, Class)} method. - */ - @Deprecated - public static <T> SQLSelect<T> scalarQuery(Class<T> type, String dataMapName, String sql) { - SQLSelect<T> query = new SQLSelect<>(sql); - query.dataMapName = dataMapName; - return query.resultColumnsTypes(type).useScalar(); - } - /** * Creates query that selects scalar value and uses default routing * @@ -135,18 +114,6 @@ public class SQLSelect<T> extends IndirectQuery implements Select<T> { return query.resultColumnsTypes(type).useScalar(); } - /** - * Creates query that selects scalar value and uses default routing - * - * @since 4.1 - * @deprecated since 4.2. Use {@link #columnQuery(String)} - */ - @Deprecated - public static SQLSelect<Object[]> scalarQuery(String sql) { - SQLSelect<Object[]> query = new SQLSelect<>(sql); - return query.useScalar(); - } - /** * Creates query that selects scalar values (as Object[]) and uses default routing * @@ -157,19 +124,6 @@ public class SQLSelect<T> extends IndirectQuery implements Select<T> { return query.useScalar(); } - /** - * Creates query that selects scalar values (as Object[]) and uses routing based on the - * provided DataMap name. - * @since 4.1 - * @deprecated since 4.2. Use {@link #columnQuery(String, String)} - */ - @Deprecated - public static SQLSelect<Object[]> scalarQuery(String sql, String dataMapName) { - SQLSelect<Object[]> query = new SQLSelect<>(sql); - query.dataMapName = dataMapName; - return query.useScalar(); - } - /** * Creates query that selects scalar values (as Object[]) and uses routing based on the * provided DataMap name. @@ -182,18 +136,6 @@ public class SQLSelect<T> extends IndirectQuery implements Select<T> { return query.useScalar(); } - /** - * Creates query that selects scalar values (as Object[]) and uses default routing - * - * @since 4.1 - * @deprecated since 4.2. Use {@link #columnQuery(String, Class...)} - */ - @Deprecated - public static SQLSelect<Object[]> scalarQuery(String sql, Class<?>... types) { - SQLSelect<Object[]> query = new SQLSelect<>(sql); - return query.resultColumnsTypes(types).useScalar(); - } - /** * Creates query that selects scalar values (as Object[]) and uses default routing * @@ -204,22 +146,6 @@ public class SQLSelect<T> extends IndirectQuery implements Select<T> { return query.resultColumnsTypes(types).useScalar(); } - /** - * Creates query that selects scalar values (as Object[]) and uses routing based on the - * provided DataMap name. - * - * @since 4.1 - * @deprecated since 4.2. Use {@link #columnQuery(String, String, Class...)} - */ - @Deprecated - public static SQLSelect<Object[]> scalarQuery(String sql, - String dataMapName, - Class<?>... types) { - SQLSelect<Object[]> query = new SQLSelect<>(sql); - query.dataMapName = dataMapName; - return query.resultColumnsTypes(types).useScalar(); - } - /** * Creates query that selects scalar values (as Object[]) and uses routing based on the * provided DataMap name. @@ -321,16 +247,6 @@ public class SQLSelect<T> extends IndirectQuery implements Select<T> { return this; } - /** - * @deprecated since 4.2 - * Use {@link #param(String, Object)} - */ - @Deprecated - public SQLSelect<T> params(String name, Object value) { - params(Collections.singletonMap(name, value)); - return this; - } - /** * @since 4.2 */ diff --git a/cayenne-server/src/main/java/org/apache/cayenne/tx/DefaultTransactionDescriptor.java b/cayenne-server/src/main/java/org/apache/cayenne/tx/DefaultTransactionDescriptor.java index b5933164c..76fff71b3 100644 --- a/cayenne-server/src/main/java/org/apache/cayenne/tx/DefaultTransactionDescriptor.java +++ b/cayenne-server/src/main/java/org/apache/cayenne/tx/DefaultTransactionDescriptor.java @@ -24,13 +24,14 @@ package org.apache.cayenne.tx; */ public class DefaultTransactionDescriptor extends TransactionDescriptor { - private static final DefaultTransactionDescriptor instance = new DefaultTransactionDescriptor(); + private static final TransactionDescriptor instance = TransactionDescriptor + .builder() + .isolation(TransactionDescriptor.ISOLATION_DEFAULT) + .propagation(TransactionPropagation.NESTED) + .build(); public static TransactionDescriptor getInstance() { return instance; } - private DefaultTransactionDescriptor() { - super(TransactionDescriptor.ISOLATION_DEFAULT, TransactionPropagation.NESTED); - } } diff --git a/cayenne-server/src/main/java/org/apache/cayenne/tx/TransactionDescriptor.java b/cayenne-server/src/main/java/org/apache/cayenne/tx/TransactionDescriptor.java index 734132a9f..54d769c26 100644 --- a/cayenne-server/src/main/java/org/apache/cayenne/tx/TransactionDescriptor.java +++ b/cayenne-server/src/main/java/org/apache/cayenne/tx/TransactionDescriptor.java @@ -47,50 +47,7 @@ public class TransactionDescriptor { private Supplier<Connection> connectionSupplier; - private TransactionDescriptor() { - } - - /** - * @param isolation one of the following <code>Connection</code> constants: - * <code>Connection.TRANSACTION_READ_UNCOMMITTED</code>, - * <code>Connection.TRANSACTION_READ_COMMITTED</code>, - * <code>Connection.TRANSACTION_REPEATABLE_READ</code>, - * <code>Connection.TRANSACTION_SERIALIZABLE</code>, or - * <code>TransactionDescriptor.ISOLATION_DEFAULT</code> - * @param propagation transaction propagation behaviour - * @see TransactionPropagation - * @deprecated since 4.2. Use {@link #builder()} method instead. - */ - @Deprecated - public TransactionDescriptor(int isolation, TransactionPropagation propagation) { - this.isolation = isolation; - this.propagation = propagation; - } - - /** - * Create transaction descriptor with desired isolation level and <code>NESTED</code> propagation - * - * @param isolation one of the following <code>Connection</code> constants: - * <code>Connection.TRANSACTION_READ_UNCOMMITTED</code>, - * <code>Connection.TRANSACTION_READ_COMMITTED</code>, - * <code>Connection.TRANSACTION_REPEATABLE_READ</code>, - * <code>Connection.TRANSACTION_SERIALIZABLE</code>, or - * <code>TransactionDescriptor.ISOLATION_DEFAULT</code> - * @deprecated since 4.2. Use {@link #builder()} method instead. - */ - @Deprecated - public TransactionDescriptor(int isolation) { - this(isolation, TransactionPropagation.NESTED); - } - - /** - * @param propagation transaction propagation behaviour - * @see TransactionPropagation - * @deprecated since 4.2. Use {@link #builder()} method instead. - */ - @Deprecated - public TransactionDescriptor(TransactionPropagation propagation) { - this(ISOLATION_DEFAULT, propagation); + protected TransactionDescriptor() { } /** diff --git a/cayenne-server/src/test/java/org/apache/cayenne/CayenneExceptionTest.java b/cayenne-server/src/test/java/org/apache/cayenne/CayenneExceptionTest.java deleted file mode 100644 index 6a82b1894..000000000 --- a/cayenne-server/src/test/java/org/apache/cayenne/CayenneExceptionTest.java +++ /dev/null @@ -1,75 +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; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; - -@Deprecated -public class CayenneExceptionTest { - - @Test - public void testConstructor1() throws Exception { - CayenneException ex = new CayenneException(); - assertNull(ex.getCause()); - assertTrue(ex.getMessage().startsWith(CayenneException.getExceptionLabel())); - } - - @Test - public void testConstructor2() throws Exception { - CayenneException ex = new CayenneException("abc"); - assertNull(ex.getCause()); - assertEquals(CayenneException.getExceptionLabel() + "abc", ex.getMessage()); - } - - @Test - public void testConstructor3() throws Exception { - Throwable cause = new Throwable(); - CayenneException ex = new CayenneException(cause); - assertSame(cause, ex.getCause()); - assertEquals(CayenneException.getExceptionLabel() + cause.toString(), ex - .getMessage()); - } - - @Test - public void testConstructor4() throws Exception { - Throwable cause = new Throwable(); - CayenneException ex = new CayenneException("abc", cause); - assertSame(cause, ex.getCause()); - assertEquals(CayenneException.getExceptionLabel() + "abc", ex.getMessage()); - } - - @Test - public void testMessageFormatting1() throws Exception { - CayenneException ex = new CayenneException("x%sx%sx", "a", "b"); - assertEquals("xaxbx", ex.getUnlabeledMessage()); - } - - @Test - public void testMessageFormatting2() throws Exception { - Throwable cause = new Throwable(); - CayenneException ex = new CayenneException("x%sx%sx", cause, "a", "b"); - assertEquals("xaxbx", ex.getUnlabeledMessage()); - } -} diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DbArcIdTest.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DbArcIdTest.java deleted file mode 100644 index dacd23954..000000000 --- a/cayenne-server/src/test/java/org/apache/cayenne/access/DbArcIdTest.java +++ /dev/null @@ -1,74 +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.access; - -import org.apache.cayenne.ObjectId; -import org.apache.cayenne.map.DbRelationship; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; - -public class DbArcIdTest { - - @Test - public void testHashCode() { - - DbArcId id1 = new DbArcId(ObjectId.of("x", "k", "v"), - new DbRelationship("r1")); - int h1 = id1.hashCode(); - assertEquals(h1, id1.hashCode()); - assertEquals(h1, id1.hashCode()); - - DbArcId id1_eq = new DbArcId(ObjectId.of("x", "k", "v"), - new DbRelationship("r1")); - assertEquals(h1, id1_eq.hashCode()); - - DbArcId id2 = new DbArcId(ObjectId.of("x", "k", "v"), - new DbRelationship("r2")); - assertNotEquals(h1, id2.hashCode()); - - DbArcId id3 = new DbArcId(ObjectId.of("y", "k", "v"), - new DbRelationship("r1")); - assertNotEquals(h1, id3.hashCode()); - } - - @Test - public void testEquals() { - - DbArcId id1 = new DbArcId(ObjectId.of("x", "k", "v"), - new DbRelationship("r1")); - assertEquals(id1, id1); - - DbArcId id1_eq = new DbArcId(ObjectId.of("x", "k", "v"), - new DbRelationship("r1")); - assertEquals(id1, id1_eq); - assertEquals(id1_eq, id1); - - DbArcId id2 = new DbArcId(ObjectId.of("x", "k", "v"), - new DbRelationship("r2")); - assertNotEquals(id1, id2); - - DbArcId id3 = new DbArcId(ObjectId.of("y", "k", "v"), - new DbRelationship("r1")); - assertNotEquals(id1, id3); - - assertNotEquals(id1, new Object()); - } -} diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/FlattenedArcKeyIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/FlattenedArcKeyIT.java deleted file mode 100644 index ea8116659..000000000 --- a/cayenne-server/src/test/java/org/apache/cayenne/access/FlattenedArcKeyIT.java +++ /dev/null @@ -1,98 +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.access; - -import org.apache.cayenne.ObjectId; -import org.apache.cayenne.di.Inject; -import org.apache.cayenne.map.EntityResolver; -import org.apache.cayenne.map.ObjRelationship; -import org.apache.cayenne.testdo.relationships_flattened.FlattenedTest1; -import org.apache.cayenne.testdo.relationships_flattened.FlattenedTest3; -import org.apache.cayenne.unit.di.server.CayenneProjects; -import org.apache.cayenne.unit.di.server.ServerCase; -import org.apache.cayenne.unit.di.server.UseServerRuntime; -import org.junit.Test; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; - -@UseServerRuntime(CayenneProjects.RELATIONSHIPS_FLATTENED_PROJECT) -public class FlattenedArcKeyIT extends ServerCase { - - @Inject - private EntityResolver entityResolver; - - @Test - public void testAttributes() { - ObjectId src = ObjectId.of("X"); - ObjectId target = ObjectId.of("Y"); - ObjRelationship r1 = entityResolver.getObjEntity(FlattenedTest3.class).getRelationship( - FlattenedTest3.TO_FT1.getName()); - - FlattenedArcKey update = new FlattenedArcKey(src, target, r1); - - assertSame(src, update.id1.getSourceId()); - assertSame(target, update.id2.getSourceId()); - assertSame(r1, update.relationship); - } - - @Test - public void testHashCode() { - ObjectId src = ObjectId.of("X"); - ObjectId target = ObjectId.of("Y"); - ObjRelationship r1 = entityResolver.getObjEntity(FlattenedTest3.class).getRelationship( - FlattenedTest3.TO_FT1.getName()); - - FlattenedArcKey update = new FlattenedArcKey(src, target, r1); - FlattenedArcKey update1 = new FlattenedArcKey(target, src, r1.getReverseRelationship()); - - ObjRelationship r3 = entityResolver.getObjEntity(FlattenedTest1.class).getRelationship( - FlattenedTest1.FT3OVER_COMPLEX.getName()); - - FlattenedArcKey update2 = new FlattenedArcKey(target, src, r3); - - int h = update.hashCode(); - int h1 = update1.hashCode(); - int h2 = update2.hashCode(); - assertTrue(h == h1); - assertTrue(h == update.hashCode()); - assertFalse(h == h2); - } - - @Test - public void testEquals() { - ObjectId src = ObjectId.of("X"); - ObjectId target = ObjectId.of("Y"); - ObjRelationship r1 = entityResolver.getObjEntity(FlattenedTest3.class).getRelationship( - FlattenedTest3.TO_FT1.getName()); - - FlattenedArcKey update = new FlattenedArcKey(src, target, r1); - FlattenedArcKey update1 = new FlattenedArcKey(target, src, r1.getReverseRelationship()); - - ObjRelationship r3 = entityResolver.getObjEntity(FlattenedTest1.class).getRelationship( - FlattenedTest1.FT3OVER_COMPLEX.getName()); - - FlattenedArcKey update2 = new FlattenedArcKey(target, src, r3); - - assertTrue(update.equals(update1)); - assertFalse(update.equals(update2)); - } -} diff --git a/cayenne-server/src/test/java/org/apache/cayenne/query/SQLSelectIT.java b/cayenne-server/src/test/java/org/apache/cayenne/query/SQLSelectIT.java index 0a4e71ece..7c0128c83 100644 --- a/cayenne-server/src/test/java/org/apache/cayenne/query/SQLSelectIT.java +++ b/cayenne-server/src/test/java/org/apache/cayenne/query/SQLSelectIT.java @@ -270,7 +270,7 @@ public class SQLSelectIT extends ServerCase { public void testObjectArrayWithCustomTypeMappedToPojo() throws SQLException { createArtistDataSet(); - List<ArtistDataWrapper> result = SQLSelect.scalarQuery("SELECT * FROM ARTIST_CT", + List<ArtistDataWrapper> result = SQLSelect.columnQuery("SELECT * FROM ARTIST_CT", Integer.class, String.class, LocalDateTime.class) .map(ArtistDataWrapper::new) .select(context); diff --git a/cayenne-velocity/src/main/java/org/apache/cayenne/velocity/SQLTemplateResourceManager.java b/cayenne-velocity/src/main/java/org/apache/cayenne/velocity/SQLTemplateResourceManager.java deleted file mode 100644 index 20fbefb08..000000000 --- a/cayenne-velocity/src/main/java/org/apache/cayenne/velocity/SQLTemplateResourceManager.java +++ /dev/null @@ -1,108 +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.velocity; - -import org.apache.cayenne.util.concurrentlinkedhashmap.ConcurrentLinkedHashMap; -import org.apache.velocity.Template; -import org.apache.velocity.exception.ParseErrorException; -import org.apache.velocity.exception.ResourceNotFoundException; -import org.apache.velocity.runtime.RuntimeServices; -import org.apache.velocity.runtime.resource.Resource; -import org.apache.velocity.runtime.resource.ResourceManager; -import org.apache.velocity.runtime.resource.loader.ResourceLoader; -import org.apache.velocity.util.ExtProperties; - -import java.io.ByteArrayInputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.util.Map; - -/** - * An implementation of the Velocity ResourceManager and ResourceLoader that - * creates templates from in-memory Strings. - * - * @since 1.1 - * @deprecated since 4.1 is unused - */ -@Deprecated -public class SQLTemplateResourceManager - extends ResourceLoader - implements ResourceManager { - - protected Map<String, Template> templateCache; - - public void initialize(RuntimeServices rs) { - super.rsvc = rs; - this.templateCache = new ConcurrentLinkedHashMap.Builder<String, Template>().maximumWeightedCapacity(100).build(); - } - - public void clearCache() { - templateCache.clear(); - } - - /** - * Returns a Velocity Resource which is a Template for the given SQL. - */ - public Resource getResource(String resourceName, int resourceType, String encoding) - throws ResourceNotFoundException, ParseErrorException { - - synchronized (templateCache) { - Template resource = templateCache.get(resourceName); - - if (resource == null) { - resource = new Template(); - resource.setRuntimeServices(rsvc); - resource.setResourceLoader(this); - resource.setName(resourceName); - resource.setEncoding(encoding); - resource.process(); - - templateCache.put(resourceName, resource); - } - - return resource; - } - } - - public String getLoaderNameForResource(String resourceName) { - return getClass().getName(); - } - - @Override - public long getLastModified(Resource resource) { - return -1; - } - - @Override - public Reader getResourceReader(String source, String charset) - throws ResourceNotFoundException { - return new InputStreamReader(new ByteArrayInputStream(source.getBytes())); - } - - @Override - public void init(ExtProperties configuration) { - - } - - @Override - public boolean isSourceModified(Resource resource) { - return false; - } -} diff --git a/modeler/cayenne-wocompat/src/main/java/org/apache/cayenne/wocompat/EOModelProcessor.java b/modeler/cayenne-wocompat/src/main/java/org/apache/cayenne/wocompat/EOModelProcessor.java index 5708bc1ff..cb925f487 100644 --- a/modeler/cayenne-wocompat/src/main/java/org/apache/cayenne/wocompat/EOModelProcessor.java +++ b/modeler/cayenne-wocompat/src/main/java/org/apache/cayenne/wocompat/EOModelProcessor.java @@ -32,6 +32,7 @@ import org.apache.cayenne.map.QueryDescriptor; import org.apache.cayenne.map.SQLTemplateDescriptor; import org.apache.cayenne.map.SelectQueryDescriptor; import org.apache.cayenne.query.Ordering; +import org.apache.cayenne.query.PrefetchTreeNode; import org.apache.cayenne.query.QueryMetadata; import org.apache.cayenne.query.SortOrder; import org.apache.cayenne.wocompat.parser.Parser; @@ -271,7 +272,7 @@ public class EOModelProcessor { if (prefetches != null && !prefetches.isEmpty()) { Iterator it = prefetches.iterator(); while (it.hasNext()) { - descriptor.addPrefetch((String) it.next()); + descriptor.addPrefetch((String) it.next(), PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS); } } diff --git a/modeler/cayenne-wocompat/src/main/java/org/apache/cayenne/wocompat/EOQuery.java b/modeler/cayenne-wocompat/src/main/java/org/apache/cayenne/wocompat/EOQuery.java index e06efa6a7..5e14c8176 100644 --- a/modeler/cayenne-wocompat/src/main/java/org/apache/cayenne/wocompat/EOQuery.java +++ b/modeler/cayenne-wocompat/src/main/java/org/apache/cayenne/wocompat/EOQuery.java @@ -109,14 +109,6 @@ public class EOQuery<T> extends SelectQuery<T> { } } - /** - * Since 4.1 is unused. - */ - @Deprecated - public String getEOName() { - return null; - } - public Collection getBindingNames() { if (bindings == null) { initBindings();