Skip to content

Commit

Permalink
[Blazebit#1557] Add BlazeCriteriaQuery.applyToCriteriaBuilder to allo…
Browse files Browse the repository at this point in the history
…w using a JPA Criteria query as set operand
  • Loading branch information
beikov committed Dec 29, 2022
1 parent 087aa00 commit 634b7f5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
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

0 comments on commit 634b7f5

Please sign in to comment.