Java Code Examples for javax.persistence.criteria.Join#on()
The following examples show how to use
javax.persistence.criteria.Join#on() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FieldCriteria.java From onedev with MIT License | 6 votes |
@Override public final Predicate getPredicate(Root<Issue> root, CriteriaBuilder builder) { Join<?, ?> join = root.join(Issue.PROP_FIELDS, JoinType.LEFT); Predicate valuePredicate = getValuePredicate(join, builder); if (valuePredicate != null) { join.on(builder.and( builder.equal(join.get(IssueField.PROP_NAME), getFieldName()), getValuePredicate(join, builder))); return join.isNotNull(); } else { join.on(builder.and( builder.equal(join.get(IssueField.PROP_NAME), getFieldName()), builder.or(builder.isNull(join.get(IssueField.PROP_VALUE))))); Join<?, ?> join2 = root.join(Issue.PROP_FIELDS, JoinType.LEFT); join2.on(builder.equal(join2.get(IssueField.PROP_NAME), getFieldName())); return builder.or(join.isNotNull(), join2.isNull()); } }
Example 2
Source File: OwnedByCriteria.java From onedev with MIT License | 6 votes |
@Override public Predicate getPredicate(Root<Project> root, CriteriaBuilder builder) { Join<?, ?> userAuthorizationJoin = root.join(Project.PROP_USER_AUTHORIZATIONS, JoinType.LEFT); userAuthorizationJoin.on(builder.and( builder.equal(userAuthorizationJoin.get(UserAuthorization.PROP_ROLE), Role.OWNER_ID), builder.equal(userAuthorizationJoin.get(UserAuthorization.PROP_USER), user))); if (user.getGroups().isEmpty()) { return userAuthorizationJoin.isNotNull(); } else { Join<?, ?> groupAuthorizationJoin = root.join(Project.PROP_GROUP_AUTHORIZATIONS, JoinType.LEFT); groupAuthorizationJoin.on(builder.and( builder.equal(groupAuthorizationJoin.get(GroupAuthorization.PROP_ROLE), Role.OWNER_ID), groupAuthorizationJoin.get(GroupAuthorization.PROP_GROUP).in(user.getGroups()))); return builder.or(userAuthorizationJoin.isNotNull(), groupAuthorizationJoin.isNotNull()); } }
Example 3
Source File: OwnedByNoneCriteria.java From onedev with MIT License | 5 votes |
@Override public Predicate getPredicate(Root<Project> root, CriteriaBuilder builder) { Join<?, ?> userAuthorizationJoin = root.join(Project.PROP_USER_AUTHORIZATIONS, JoinType.LEFT); Join<?, ?> groupAuthorizationJoin = root.join(Project.PROP_GROUP_AUTHORIZATIONS, JoinType.LEFT); userAuthorizationJoin.on(builder.equal( userAuthorizationJoin.get(UserAuthorization.PROP_ROLE), Role.OWNER_ID)); groupAuthorizationJoin.on( builder.equal(groupAuthorizationJoin.get(GroupAuthorization.PROP_ROLE), Role.OWNER_ID)); return builder.and(userAuthorizationJoin.isNull(), groupAuthorizationJoin.isNull()); }
Example 4
Source File: RequestedForChangesByMeCriteria.java From onedev with MIT License | 5 votes |
@Override public Predicate getPredicate(Root<PullRequest> root, CriteriaBuilder builder) { if (User.get() != null) { Join<?, ?> join = root.join(PullRequest.PROP_REVIEWS, JoinType.LEFT); Path<?> userPath = EntityQuery.getPath(join, PullRequestReview.PROP_USER); Path<?> approvedPath = EntityQuery.getPath(join, PullRequestReview.PROP_RESULT + "." + ReviewResult.PROP_APPROVED); join.on(builder.and( builder.equal(userPath, User.get()), builder.equal(approvedPath, false))); return join.isNotNull(); } else { throw new OneException("Please login to perform this query"); } }
Example 5
Source File: ToBeReviewedByMeCriteria.java From onedev with MIT License | 5 votes |
@Override public Predicate getPredicate(Root<PullRequest> root, CriteriaBuilder builder) { if (User.get() != null) { Join<?, ?> join = root.join(PullRequest.PROP_REVIEWS, JoinType.LEFT); Path<?> userPath = EntityQuery.getPath(join, PullRequestReview.PROP_USER); Path<?> approvedPath = EntityQuery.getPath(join, PullRequestReview.PROP_RESULT + "." + ReviewResult.PROP_APPROVED); join.on(builder.and( builder.equal(userPath, User.get()), builder.isNull(approvedPath))); return join.isNotNull(); } else { throw new OneException("Please login to perform this query"); } }
Example 6
Source File: HasFailedBuildsCriteria.java From onedev with MIT License | 5 votes |
@Override public Predicate getPredicate(Root<PullRequest> root, CriteriaBuilder builder) { Join<?, ?> join = root .join(PullRequest.PROP_VERIFICATIONS, JoinType.LEFT) .join(PullRequestVerification.PROP_BUILD, JoinType.INNER); Path<?> status = join.get(Build.STATUS); join.on(builder.or( builder.equal(status, Build.Status.FAILED), builder.equal(status, Build.Status.CANCELLED), builder.equal(status, Build.Status.TIMED_OUT))); return join.isNotNull(); }
Example 7
Source File: ParamCriteria.java From onedev with MIT License | 5 votes |
@Override public Predicate getPredicate(Root<Build> root, CriteriaBuilder builder) { Join<?, ?> join = root.join(Build.PROP_PARAMS, JoinType.LEFT); join.on(builder.and( builder.equal(join.get(BuildParam.PROP_NAME), name)), builder.equal(join.get(BuildParam.PROP_VALUE), value)); return join.isNotNull(); }
Example 8
Source File: ToBeVerifiedByBuildsCriteria.java From onedev with MIT License | 5 votes |
@Override public Predicate getPredicate(Root<PullRequest> root, CriteriaBuilder builder) { Join<?, ?> join = root .join(PullRequest.PROP_VERIFICATIONS, JoinType.LEFT) .join(PullRequestVerification.PROP_BUILD, JoinType.INNER); Path<?> status = join.get(Build.STATUS); join.on(builder.or( builder.equal(status, Build.Status.RUNNING), builder.equal(status, Build.Status.PENDING), builder.equal(status, Build.Status.WAITING))); return join.isNotNull(); }
Example 9
Source File: AssignedToCriteria.java From onedev with MIT License | 5 votes |
@Override public Predicate getPredicate(Root<PullRequest> root, CriteriaBuilder builder) { Join<?, ?> join = root.join(PullRequest.PROP_ASSIGNMENTS, JoinType.LEFT); Path<?> userPath = EntityQuery.getPath(join, PullRequestAssignment.PROP_USER); join.on(builder.equal(userPath, user)); return join.isNotNull(); }
Example 10
Source File: ApprovedByCriteria.java From onedev with MIT License | 5 votes |
@Override public Predicate getPredicate(Root<PullRequest> root, CriteriaBuilder builder) { Join<?, ?> join = root.join(PullRequest.PROP_REVIEWS, JoinType.LEFT); Path<?> userPath = EntityQuery.getPath(join, PullRequestReview.PROP_USER); Path<?> approvedPath = EntityQuery.getPath(join, PullRequestReview.PROP_RESULT + "." + ReviewResult.PROP_APPROVED); join.on(builder.and( builder.equal(userPath, user), builder.equal(approvedPath, true))); return join.isNotNull(); }
Example 11
Source File: AssignedToMeCriteria.java From onedev with MIT License | 5 votes |
@Override public Predicate getPredicate(Root<PullRequest> root, CriteriaBuilder builder) { if (User.get() != null) { Join<?, ?> join = root.join(PullRequest.PROP_ASSIGNMENTS, JoinType.LEFT); Path<?> userPath = EntityQuery.getPath(join, PullRequestAssignment.PROP_USER); join.on(builder.equal(userPath, User.get())); return join.isNotNull(); } else { throw new OneException("Please login to perform this query"); } }
Example 12
Source File: ToBeReviewedByCriteria.java From onedev with MIT License | 5 votes |
@Override public Predicate getPredicate(Root<PullRequest> root, CriteriaBuilder builder) { Join<?, ?> join = root.join(PullRequest.PROP_REVIEWS, JoinType.LEFT); Path<?> userPath = EntityQuery.getPath(join, PullRequestReview.PROP_USER); Path<?> approvedPath = EntityQuery.getPath(join, PullRequestReview.PROP_RESULT + "." + ReviewResult.PROP_APPROVED); join.on(builder.and( builder.equal(userPath, user), builder.isNull(approvedPath))); return join.isNotNull(); }
Example 13
Source File: HasPendingReviewsCriteria.java From onedev with MIT License | 5 votes |
@Override public Predicate getPredicate(Root<PullRequest> root, CriteriaBuilder builder) { Join<?, ?> join = root.join(PullRequest.PROP_REVIEWS, JoinType.LEFT); Path<?> userPath = EntityQuery.getPath(join, PullRequestReview.PROP_USER); Path<?> approvedPath = EntityQuery.getPath(join, PullRequestReview.PROP_RESULT + "." + ReviewResult.PROP_APPROVED); join.on(builder.and( builder.isNotNull(userPath), builder.isNull(approvedPath))); return join.isNotNull(); }
Example 14
Source File: RequestedForChangesByCriteria.java From onedev with MIT License | 5 votes |
@Override public Predicate getPredicate(Root<PullRequest> root, CriteriaBuilder builder) { Join<?, ?> join = root.join(PullRequest.PROP_REVIEWS, JoinType.LEFT); Path<?> userPath = EntityQuery.getPath(join, PullRequestReview.PROP_USER); Path<?> approvedPath = EntityQuery.getPath(join, PullRequestReview.PROP_RESULT + "." + ReviewResult.PROP_APPROVED); join.on(builder.and( builder.equal(userPath, user), builder.equal(approvedPath, false))); return join.isNotNull(); }
Example 15
Source File: ReplyCriteria.java From onedev with MIT License | 5 votes |
@Override public Predicate getPredicate(Root<CodeComment> root, CriteriaBuilder builder) { Join<?, ?> join = root.join(CodeComment.PROP_REPLIES, JoinType.LEFT); Path<String> attribute = join.get(CodeCommentReply.PROP_CONTENT); join.on(builder.like(builder.lower(attribute), "%" + value.toLowerCase().replace('*', '%') + "%")); return join.isNotNull(); }
Example 16
Source File: DefaultIssueManager.java From onedev with MIT License | 5 votes |
private CriteriaQuery<Issue> buildCriteriaQuery(@Nullable Project project, Session session, EntityQuery<Issue> issueQuery) { CriteriaBuilder builder = session.getCriteriaBuilder(); CriteriaQuery<Issue> query = builder.createQuery(Issue.class); Root<Issue> root = query.from(Issue.class); query.where(getPredicates(project, issueQuery.getCriteria(), root, builder)); List<javax.persistence.criteria.Order> orders = new ArrayList<>(); for (EntitySort sort: issueQuery.getSorts()) { if (Issue.ORDER_FIELDS.containsKey(sort.getField())) { if (sort.getDirection() == Direction.ASCENDING) orders.add(builder.asc(IssueQuery.getPath(root, Issue.ORDER_FIELDS.get(sort.getField())))); else orders.add(builder.desc(IssueQuery.getPath(root, Issue.ORDER_FIELDS.get(sort.getField())))); } else { Join<Issue, IssueField> join = root.join(Issue.PROP_FIELDS, JoinType.LEFT); join.on(builder.equal(join.get(IssueField.PROP_NAME), sort.getField())); if (sort.getDirection() == Direction.ASCENDING) orders.add(builder.asc(join.get(IssueField.PROP_ORDINAL))); else orders.add(builder.desc(join.get(IssueField.PROP_ORDINAL))); } } if (orders.isEmpty()) { orders.add(builder.desc(IssueQuery.getPath(root, Issue.PROP_LAST_UPDATE + "." + LastUpdate.PROP_DATE))); } query.orderBy(orders); return query; }
Example 17
Source File: AssociatedWithPullRequestCriteria.java From onedev with MIT License | 4 votes |
@Override public Predicate getPredicate(Root<Build> root, CriteriaBuilder builder) { Join<?, ?> join = root.join(Build.PROP_VERIFICATIONS, JoinType.LEFT); join.on(builder.equal(join.get(PullRequestVerification.PROP_REQUEST), request)); return builder.equal(root.get(Build.PROP_PROJECT), request.getTargetProject()); }
Example 18
Source File: DependsOnCriteria.java From onedev with MIT License | 4 votes |
@Override public Predicate getPredicate(Root<Build> root, CriteriaBuilder builder) { Join<?, ?> join = root.join(Build.PROP_DEPENDENCIES, JoinType.LEFT); join.on(builder.equal(join.get(BuildDependence.PROP_DEPENDENCY), build)); return join.isNotNull(); }
Example 19
Source File: RequiredByPullRequestsCriteria.java From onedev with MIT License | 4 votes |
@Override public Predicate getPredicate(Root<Build> root, CriteriaBuilder builder) { Join<?, ?> join = root.join(Build.PROP_VERIFICATIONS, JoinType.LEFT); join.on(builder.equal(join.get(PullRequestVerification.PROP_REQUIRED), true)); return join.isNotNull(); }
Example 20
Source File: DependenciesOfCriteria.java From onedev with MIT License | 4 votes |
@Override public Predicate getPredicate(Root<Build> root, CriteriaBuilder builder) { Join<?, ?> join = root.join(Build.PROP_DEPENDENTS, JoinType.LEFT); join.on(builder.equal(join.get(BuildDependence.PROP_DEPENDENT), build)); return join.isNotNull(); }