diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/eu/mulk/mulkcms2/benki/newsletter/NewsletterSender.java | 23 |
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()) { |