Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#1557] Add BlazeCriteriaQuery.applyToCriteriaBuilder to allow using a JPA Criteria query as set operand #1659

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Changes that happened in releases

### New features

None yet
* Add `BlazeCriteriaQuery.applyToCriteriaBuilder` to allow using a JPA Criteria query as set operand

### Bug fixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package com.blazebit.persistence.criteria;

import com.blazebit.persistence.BaseCriteriaBuilder;
import com.blazebit.persistence.BaseQueryBuilder;
import com.blazebit.persistence.CriteriaBuilder;

import javax.persistence.EntityManager;
Expand Down Expand Up @@ -43,6 +45,14 @@ public interface BlazeCriteriaQuery<T> extends CriteriaQuery<T>, BlazeAbstractQu
*/
public CriteriaBuilder<T> createCriteriaBuilder(EntityManager entityManager);

/**
* Applies this criteria query onto an existing Blaze-Persistence Core {@link BaseCriteriaBuilder}.
*
* @param criteriaBuilder The criteria builder to apply this criteria query onto
* @since 1.6.9
*/
public void applyToCriteriaBuilder(BaseCriteriaBuilder<T, ?> criteriaBuilder);

/**
* The extended JPA {@link javax.persistence.criteria.CriteriaBuilder} associated with this query.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package com.blazebit.persistence.criteria.impl;

import com.blazebit.persistence.BaseCriteriaBuilder;
import com.blazebit.persistence.BaseQueryBuilder;
import com.blazebit.persistence.CriteriaBuilder;
import com.blazebit.persistence.criteria.BlazeCriteriaBuilder;
import com.blazebit.persistence.criteria.BlazeCriteriaQuery;
Expand Down Expand Up @@ -280,4 +282,8 @@ public CriteriaBuilder<T> createCriteriaBuilder(EntityManager entityManager) {
return query.render(cb);
}

@Override
public void applyToCriteriaBuilder(BaseCriteriaBuilder<T, ?> criteriaBuilder) {
query.render(criteriaBuilder);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,7 @@

package com.blazebit.persistence.criteria.impl;

import com.blazebit.persistence.BaseSubqueryBuilder;
import com.blazebit.persistence.CriteriaBuilder;
import com.blazebit.persistence.FromBuilder;
import com.blazebit.persistence.FullQueryBuilder;
import com.blazebit.persistence.GroupByBuilder;
import com.blazebit.persistence.HavingBuilder;
import com.blazebit.persistence.JoinOnBuilder;
import com.blazebit.persistence.JoinType;
import com.blazebit.persistence.MultipleSubqueryInitiator;
import com.blazebit.persistence.OrderByBuilder;
import com.blazebit.persistence.SelectBuilder;
import com.blazebit.persistence.SelectObjectBuilder;
import com.blazebit.persistence.SubqueryBuilder;
import com.blazebit.persistence.SubqueryInitiator;
import com.blazebit.persistence.WhereBuilder;
import com.blazebit.persistence.*;
import com.blazebit.persistence.criteria.BlazeAbstractQuery;
import com.blazebit.persistence.criteria.BlazeJoin;
import com.blazebit.persistence.criteria.BlazeOrder;
Expand Down Expand Up @@ -271,7 +257,7 @@ public <U> BlazeSubquery<U> subquery(Class<U> subqueryType) {

/* Rendering */

public CriteriaBuilder<T> render(CriteriaBuilder<T> cb) {
public <X extends BaseCriteriaBuilder<T, ?>> X render(X cb) {
if (distinct) {
cb.distinct();
}
Expand Down