Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jpa.repository.support;
import java.util.List;
import javax.persistence.EntityManager;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Order;
import org.springframework.data.jpa.provider.PersistenceProvider;
import org.springframework.data.mapping.PropertyPath;
import org.springframework.data.querydsl.QSort;
import org.springframework.util.Assert;
import com.querydsl.core.types.EntityPath;
import com.querydsl.core.types.Expression;
import com.querydsl.core.types.OrderSpecifier;
import com.querydsl.core.types.OrderSpecifier.NullHandling;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.dsl.Expressions;
import com.querydsl.core.types.dsl.PathBuilder;
import com.querydsl.jpa.EclipseLinkTemplates;
import com.querydsl.jpa.HQLTemplates;
import com.querydsl.jpa.JPQLQuery;
import com.querydsl.jpa.impl.AbstractJPAQuery;
import com.querydsl.jpa.impl.JPAQuery;
/**
* Helper instance to ease access to Querydsl JPA query API.
*
* @author Oliver Gierke
* @author Thomas Darimont
* @author Mark Paluch
* @author Christoph Strobl
* @author Marcus Voltolim
*/
public class Querydsl {
private final EntityManager em;
private final PersistenceProvider provider;
private final PathBuilder builder;
/**
* Creates a new {@link Querydsl} for the given {@link EntityManager} and {@link PathBuilder}.
*
* @param em must not be {@literal null}.
* @param builder must not be {@literal null}.
*/
public Querydsl(EntityManager em, PathBuilder builder) {
Assert.notNull(em, "EntityManager must not be null!");
Assert.notNull(builder, "PathBuilder must not be null!");
this.em = em;
this.provider = PersistenceProvider.fromEntityManager(em);
this.builder = builder;
}
/**
* Creates the {@link JPQLQuery} instance based on the configured {@link EntityManager}.
*
* @return
*/
public AbstractJPAQuery> createQuery() {
switch (provider) {
case ECLIPSELINK:
return new JPAQuery(em, EclipseLinkTemplates.DEFAULT);
case HIBERNATE:
return new JPAQuery(em, HQLTemplates.DEFAULT);
case GENERIC_JPA:
default:
return new JPAQuery(em);
}
}
/**
* Creates the {@link JPQLQuery} instance based on the configured {@link EntityManager}.
*
* @param paths must not be {@literal null}.
* @return
*/
public AbstractJPAQuery