BookmarkResource: Remove code duplication.
Change-Id: I63cc5452b6690e6ef9a5a0d080d97e03a6952b13
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 @@
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 @@
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) {