Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- The query will actually produce duplicates (row for each parent-child), but
- internally JPA provider (Hibernate) will filter out to just one entry for parent
- and all children.
- */
- QBookmark _bookmark = QBookmark.bookmark;
- QUser _owner = QUser.user;
- QWebUrl _webUrl = QWebUrl.webUrl;
- QRole _role = QRole.role;
- QTag _tag0 = QTag.tag;
- JPAQuery<Bookmark> query = jpaQueryFactory
- .select(_bookmark)
- .distinct()
- .from(_bookmark)
- .innerJoin(_bookmark.webUrl, _webUrl).fetchJoin()
- .innerJoin(_bookmark.owner, _owner).fetchJoin()
- .innerJoin(_owner.role, _role).fetchJoin()
- .leftJoin(_bookmark.tags, _tag0).fetchJoin()
- .where(_bookmark.tags.any().name.eq("java")
- .and(_bookmark.tags.any().name.eq("angular")));
- query.fetch().forEach(new Consumer<Bookmark>() {
- @Override public void accept(Bookmark t) {
- System.out.println(t);
- }
- });
- System.out.println(query.fetchCount());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement