diff --git a/querydsl-jpa/src/main/java/com/querydsl/jpa/impl/AbstractJPAQuery.java b/querydsl-jpa/src/main/java/com/querydsl/jpa/impl/AbstractJPAQuery.java index 0305391fd8..c67add653f 100644 --- a/querydsl-jpa/src/main/java/com/querydsl/jpa/impl/AbstractJPAQuery.java +++ b/querydsl-jpa/src/main/java/com/querydsl/jpa/impl/AbstractJPAQuery.java @@ -14,9 +14,12 @@ package com.querydsl.jpa.impl; import java.util.ArrayList; +import java.util.Collection; import java.util.LinkedHashMap; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Stream; @@ -46,9 +49,9 @@ */ public abstract class AbstractJPAQuery> extends JPAQueryBase { - private static final Logger logger = Logger.getLogger(JPAQuery.class.getName()); + private static final Logger logger = Logger.getLogger(AbstractJPAQuery.class.getName()); - protected final Map hints = new LinkedHashMap<>(); + protected final Map> hints = new LinkedHashMap<>(); protected final EntityManager entityManager; @@ -148,8 +151,8 @@ protected Query createQuery(@Nullable QueryModifiers modifiers, boolean forCount query.setFlushMode(flushMode); } - for (Map.Entry entry : hints.entrySet()) { - query.setHint(entry.getKey(), entry.getValue()); + for (Map.Entry> entry : hints.entrySet()) { + entry.getValue().forEach(value -> query.setHint(entry.getKey(), value)); } // set transformer, if necessary and possible @@ -348,7 +351,8 @@ public Q setFlushMode(FlushModeType flushMode) { @SuppressWarnings("unchecked") public Q setHint(String name, Object value) { - hints.put(name, value); + hints.computeIfAbsent(name,key -> new LinkedHashSet<>()); + hints.get(name).add(value); return (Q) this; }