summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2020-02-22 11:29:37 +0100
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2020-02-22 11:29:37 +0100
commit404ac1d20d5126c7ac5467171531d5e4a9936fc1 (patch)
tree22259e345231e62c363fc584de2309b7399267b5 /src
parent088a21f23554624b79bf4bda58ddc11d4cf7c23c (diff)
BookmarkResource: Use JPA metamodel for type-safe Criteria queries.
Change-Id: I7571a749275d733c9738eed01dad9fb2de7d77ba
Diffstat (limited to 'src')
-rw-r--r--src/main/java/eu/mulk/mulkcms2/benki/bookmarks/BookmarkResource.java13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/main/java/eu/mulk/mulkcms2/benki/bookmarks/BookmarkResource.java b/src/main/java/eu/mulk/mulkcms2/benki/bookmarks/BookmarkResource.java
index 53b7ddc..ad75c4c 100644
--- a/src/main/java/eu/mulk/mulkcms2/benki/bookmarks/BookmarkResource.java
+++ b/src/main/java/eu/mulk/mulkcms2/benki/bookmarks/BookmarkResource.java
@@ -13,6 +13,7 @@ import com.rometools.rome.io.FeedException;
import com.rometools.rome.io.WireFeedOutput;
import eu.mulk.mulkcms2.benki.accesscontrol.Role;
import eu.mulk.mulkcms2.benki.users.User;
+import eu.mulk.mulkcms2.benki.users.User_;
import io.quarkus.qute.Template;
import io.quarkus.qute.TemplateExtension;
import io.quarkus.qute.TemplateInstance;
@@ -269,9 +270,9 @@ public class BookmarkResource {
var root = query.from(Bookmark.class);
bm = root;
query.select(root);
- root.fetch("owner", JoinType.LEFT);
+ root.fetch(Bookmark_.owner, JoinType.LEFT);
- var target = root.join("targets");
+ var target = root.join(Bookmark_.targets);
query.where(cb.equal(target, Role.getWorld()));
} else {
var userName = identity.getPrincipal().getName();
@@ -279,14 +280,14 @@ public class BookmarkResource {
var root = query.from(User.class);
query.where(cb.equal(root, user));
- bm = root.join("visibleBookmarks");
- bm.fetch("owner", JoinType.LEFT);
+ bm = root.join(User_.visibleBookmarks);
+ bm.fetch(Bookmark_.owner, JoinType.LEFT);
}
- query.orderBy(cb.desc(bm.get("date")));
+ query.orderBy(cb.desc(bm.get(Bookmark_.date)));
if (owner != null) {
- query.where(cb.equal(bm.get("owner"), owner));
+ query.where(cb.equal(bm.get(Bookmark_.owner), owner));
}
var q = entityManager.createQuery(query);