From 78b77dcd82b614f5280f7d453ecf916ceacc344c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20P=C3=B6hler?= Date: Mon, 21 Aug 2023 11:50:28 +0200 Subject: [PATCH] Potential Fix for using idEq or setId in subquery --- .../server/query/CQueryPredicates.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryPredicates.java b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryPredicates.java index 78b54d56d..376dc9988 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryPredicates.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/query/CQueryPredicates.java @@ -21,10 +21,7 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Timestamp; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; import static java.lang.System.Logger.Level.WARNING; @@ -303,7 +300,20 @@ public final class CQueryPredicates { * Return the bind values for the where expression. */ public List whereExprBindValues() { - return where == null ? Collections.emptyList() : where.bindValues(); + if (idValue == null && where == null) { + return Collections.emptyList(); + } + if (where == null) { + return List.of(idValue); + } + if (idValue == null) { + return where.bindValues(); + } + + List bindValues = new ArrayList<>(); + bindValues.add(idValue); + bindValues.addAll(where.bindValues()); + return Collections.unmodifiableList(bindValues); } /**