|
| 1 | +/* |
| 2 | + * Copyright 2022 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package org.springframework.data.jpa.repository.query; |
| 17 | + |
| 18 | +import org.springframework.data.domain.Sort; |
| 19 | + |
| 20 | +/** |
| 21 | + * The implementation of {@link QueryEnhancer} using {@link QueryUtils}. |
| 22 | + * |
| 23 | + * @author Diego Krupitza |
| 24 | + */ |
| 25 | +public class DefaultQueryEnhancer implements QueryEnhancer { |
| 26 | + |
| 27 | + @Override |
| 28 | + public String getExistsQueryString(String entityName, String countQueryPlaceHolder, Iterable<String> idAttributes) { |
| 29 | + return QueryUtils.getExistsQueryString(entityName, countQueryPlaceHolder, idAttributes); |
| 30 | + } |
| 31 | + |
| 32 | + @Override |
| 33 | + public String getQueryString(String template, String entityName) { |
| 34 | + return QueryUtils.getQueryString(template, entityName); |
| 35 | + } |
| 36 | + |
| 37 | + @Override |
| 38 | + public String applySorting(DeclaredQuery query, Sort sort, String alias) { |
| 39 | + return QueryUtils.applySorting(query.getQueryString(), sort, alias); |
| 40 | + } |
| 41 | + |
| 42 | + @Override |
| 43 | + public String detectAlias(DeclaredQuery query) { |
| 44 | + return QueryUtils.detectAlias(query.getQueryString()); |
| 45 | + } |
| 46 | + |
| 47 | + @Override |
| 48 | + public String createCountQueryFor(DeclaredQuery originalQuery, String countProjection) { |
| 49 | + return QueryUtils.createCountQueryFor(originalQuery.getQueryString(), countProjection); |
| 50 | + } |
| 51 | + |
| 52 | + @Override |
| 53 | + public String getProjection(DeclaredQuery query) { |
| 54 | + return QueryUtils.getProjection(query.getQueryString()); |
| 55 | + } |
| 56 | +} |
0 commit comments