summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2022-11-08 21:42:59 +0100
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2022-11-08 21:42:59 +0100
commit601508f7937710040a3347ece5d94efc91ffb855 (patch)
tree85e8b04aedb38223b3af618420d447021e5755be /src
parent22546723aa27db95b9ababc19b38482f98129ec0 (diff)
fix(newsletter): Do not pass DISTINCT through to SQL.
This was causing an error: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list Change-Id: I2de3713fa1d7ca9d6f3592840a944e16cc8faa1d
Diffstat (limited to 'src')
-rw-r--r--src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterSender.java23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterSender.java b/src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterSender.java
index b8f2d07..949d127 100644
--- a/src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterSender.java
+++ b/src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterSender.java
@@ -27,6 +27,7 @@ import javax.persistence.PersistenceContext;
import javax.transaction.Transactional;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.hibernate.Session;
+import org.hibernate.annotations.QueryHints;
@Dependent
public class NewsletterSender {
@@ -54,16 +55,18 @@ public class NewsletterSender {
var session = em.unwrap(Session.class);
List<Post<?>> posts =
- Post.list(
- """
- SELECT DISTINCT p FROM Post p
- JOIN p.targets r
- JOIN r.tags tag
- WHERE p.newsletter IS NULL
- AND p.scope = 'top_level'
- AND tag = 'world'
- """,
- Sort.ascending("date"));
+ Post.find(
+ """
+ SELECT DISTINCT p FROM Post p
+ JOIN p.targets r
+ JOIN r.tags tag
+ WHERE p.newsletter IS NULL
+ AND p.scope = 'top_level'
+ AND tag = 'world'
+ """,
+ Sort.ascending("date"))
+ .withHint(QueryHints.PASS_DISTINCT_THROUGH, false)
+ .list();
Post.fetchTexts(posts);
if (posts.isEmpty()) {