summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2020-02-22 11:30:53 +0100
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2020-02-22 11:30:53 +0100
commitcb226699d09467e1036a06298df61628ccc6f829 (patch)
treedd7ecf3381eff8f52abd198de5898959671f7d77
parent404ac1d20d5126c7ac5467171531d5e4a9936fc1 (diff)
BookmarkResource: Remove code duplication.
Change-Id: I63cc5452b6690e6ef9a5a0d080d97e03a6952b13
-rw-r--r--src/main/java/eu/mulk/mulkcms2/benki/bookmarks/BookmarkResource.java10
1 files changed, 4 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 ad75c4c..45eeb2e 100644
--- a/src/main/java/eu/mulk/mulkcms2/benki/bookmarks/BookmarkResource.java
+++ b/src/main/java/eu/mulk/mulkcms2/benki/bookmarks/BookmarkResource.java
@@ -267,12 +267,10 @@ public class BookmarkResource {
From<?, Bookmark> bm;
if (identity.isAnonymous()) {
- var root = query.from(Bookmark.class);
- bm = root;
- query.select(root);
- root.fetch(Bookmark_.owner, JoinType.LEFT);
+ bm = query.from(Bookmark.class);
+ query.select(bm);
- var target = root.join(Bookmark_.targets);
+ var target = bm.join(Bookmark_.targets);
query.where(cb.equal(target, Role.getWorld()));
} else {
var userName = identity.getPrincipal().getName();
@@ -281,9 +279,9 @@ public class BookmarkResource {
var root = query.from(User.class);
query.where(cb.equal(root, user));
bm = root.join(User_.visibleBookmarks);
- bm.fetch(Bookmark_.owner, JoinType.LEFT);
}
+ bm.fetch(Bookmark_.owner, JoinType.LEFT);
query.orderBy(cb.desc(bm.get(Bookmark_.date)));
if (owner != null) {