From cde4f289707270c51170afead7b316f6998b6455 Mon Sep 17 00:00:00 2001 From: Will Dazey Date: Tue, 28 Feb 2023 15:40:50 -0600 Subject: [PATCH] Issue 1815: Transforming object types for collections Signed-off-by: Will Dazey --- .../internal/expressions/QueryKeyExpression.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/expressions/QueryKeyExpression.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/expressions/QueryKeyExpression.java index 22cd3a12711..bd6b8f858d3 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/expressions/QueryKeyExpression.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/internal/expressions/QueryKeyExpression.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; @@ -34,6 +35,7 @@ import org.eclipse.persistence.expressions.Expression; import org.eclipse.persistence.internal.helper.DatabaseField; import org.eclipse.persistence.internal.helper.DatabaseTable; +import org.eclipse.persistence.internal.helper.Helper; import org.eclipse.persistence.internal.identitymaps.CacheId; import org.eclipse.persistence.internal.queries.MappedKeyMapContainerPolicy; import org.eclipse.persistence.internal.sessions.AbstractRecord; @@ -424,8 +426,11 @@ public Object getFieldValue(Object objectValue, AbstractSession session) { Object fieldValue = objectValue; if (mapping != null) { if (mapping.isAbstractDirectMapping() || mapping.isDirectCollectionMapping()) { + // CR#3623207, check for IN Collection here not in mapping. - if (objectValue instanceof Collection) { + // Translate the individual elements of a collection to match the mapping, but only if the mapping is not to a collection itself + Class cls = mapping.getFieldClassification(getField()); + if (objectValue instanceof Collection && (cls != null && !(cls.isArray() || cls.isInstance(Collection.class)))) { // This can actually be a collection for IN within expressions... however it would be better for expressions to handle this. Collection values = (Collection)objectValue; Vector fieldValues = new Vector(values.size());