diff --git a/hawkbit-repository/hawkbit-repository-jpa-eclipselink/src/main/java/org/eclipse/hawkbit/repository/jpa/Jpa.java b/hawkbit-repository/hawkbit-repository-jpa-eclipselink/src/main/java/org/eclipse/hawkbit/repository/jpa/Jpa.java index ad743e032a..4f8a8ac0a2 100644 --- a/hawkbit-repository/hawkbit-repository-jpa-eclipselink/src/main/java/org/eclipse/hawkbit/repository/jpa/Jpa.java +++ b/hawkbit-repository/hawkbit-repository-jpa-eclipselink/src/main/java/org/eclipse/hawkbit/repository/jpa/Jpa.java @@ -10,6 +10,7 @@ package org.eclipse.hawkbit.repository.jpa; import java.util.Collection; +import java.util.Iterator; import java.util.List; import java.util.stream.IntStream; @@ -34,13 +35,14 @@ public enum JpaVendor { public static final char NATIVE_QUERY_PARAMETER_PREFIX = '?'; - public static String formatNativeQueryInClause(final String name, final List list) { - return formatEclipseLinkNativeQueryInClause(IntStream.range(0, list.size()).mapToObj(i -> name + "_" + i).toList()); + public static String formatNativeQueryInClause(final String name, final Collection collection) { + return formatEclipseLinkNativeQueryInClause(IntStream.range(0, collection.size()).mapToObj(i -> name + "_" + i).toList()); } - public static void setNativeQueryInParameter(final Query deleteQuery, final String name, final List list) { - for (int i = 0, len = list.size(); i < len; i++) { - deleteQuery.setParameter(name + "_" + i, list.get(i)); + public static void setNativeQueryInParameter(final Query query, final String name, final Collection collection) { + int i = 0; + for (final Iterator iterator = collection.iterator(); iterator.hasNext(); i++) { + query.setParameter(name + "_" + i, iterator.next()); } } diff --git a/hawkbit-repository/hawkbit-repository-jpa-hibernate/src/main/java/org/eclipse/hawkbit/repository/jpa/Jpa.java b/hawkbit-repository/hawkbit-repository-jpa-hibernate/src/main/java/org/eclipse/hawkbit/repository/jpa/Jpa.java index 34213c1b03..133ec77d53 100644 --- a/hawkbit-repository/hawkbit-repository-jpa-hibernate/src/main/java/org/eclipse/hawkbit/repository/jpa/Jpa.java +++ b/hawkbit-repository/hawkbit-repository-jpa-hibernate/src/main/java/org/eclipse/hawkbit/repository/jpa/Jpa.java @@ -9,6 +9,7 @@ */ package org.eclipse.hawkbit.repository.jpa; +import java.util.Collection; import java.util.List; import jakarta.persistence.Query; @@ -32,11 +33,11 @@ public enum JpaVendor { public static final char NATIVE_QUERY_PARAMETER_PREFIX = ':'; - public static String formatNativeQueryInClause(final String name, final List list) { + public static String formatNativeQueryInClause(final String name, final Collection collection) { return ":" + name; } - public static void setNativeQueryInParameter(final Query deleteQuery, final String name, final List list) { - deleteQuery.setParameter(name, list); + public static void setNativeQueryInParameter(final Query query, final String name, final Collection collection) { + query.setParameter(name, collection); } } \ No newline at end of file