-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
324 additions
and
506 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/EntityQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
* Copyright 2018-2024 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.query; | ||
|
||
import org.springframework.data.domain.Sort; | ||
import org.springframework.lang.Nullable; | ||
import org.springframework.util.ObjectUtils; | ||
|
||
/** | ||
* A wrapper for a String representation of a query offering information about the query. | ||
* | ||
* @author Jens Schauder | ||
* @author Diego Krupitza | ||
* @since 2.0.3 | ||
*/ | ||
interface EntityQuery extends IntrospectedQuery { | ||
|
||
/** | ||
* Creates a DeclaredQuery for a JPQL query. | ||
* | ||
* @param query the JPQL query string. | ||
* @return | ||
*/ | ||
static EntityQuery introspectJpql(String query, QueryEnhancerFactory queryEnhancer) { | ||
return ObjectUtils.isEmpty(query) ? EmptyIntrospectedQuery.EMPTY_QUERY | ||
: new StringQuery(query, false, queryEnhancer); | ||
} | ||
|
||
/** | ||
* Creates a DeclaredQuery for a JPQL query. | ||
* | ||
* @param query the JPQL query string. | ||
* @return | ||
*/ | ||
static EntityQuery introspectJpql(String query, QueryEnhancerSelector selector) { | ||
return ObjectUtils.isEmpty(query) ? EmptyIntrospectedQuery.EMPTY_QUERY : new StringQuery(query, false, selector); | ||
} | ||
|
||
/** | ||
* Creates a DeclaredQuery for a native query. | ||
* | ||
* @param query the native query string. | ||
* @return | ||
*/ | ||
static EntityQuery introspectNativeQuery(String query, QueryEnhancerFactory queryEnhancer) { | ||
return ObjectUtils.isEmpty(query) ? EmptyIntrospectedQuery.EMPTY_QUERY | ||
: new StringQuery(query, true, queryEnhancer); | ||
} | ||
|
||
/** | ||
* Creates a DeclaredQuery for a native query. | ||
* | ||
* @param query the native query string. | ||
* @return | ||
*/ | ||
static EntityQuery introspectNativeQuery(String query, QueryEnhancerSelector selector) { | ||
return ObjectUtils.isEmpty(query) ? EmptyIntrospectedQuery.EMPTY_QUERY : new StringQuery(query, true, selector); | ||
} | ||
|
||
/** | ||
* Returns whether the query is using a constructor expression. | ||
* | ||
* @since 1.10 | ||
*/ | ||
boolean hasConstructorExpression(); | ||
|
||
/** | ||
* Returns whether the query uses the default projection, i.e. returns the main alias defined for the query. | ||
*/ | ||
boolean isDefaultProjection(); | ||
|
||
/** | ||
* Creates a new {@literal DeclaredQuery} representing a count query, i.e. a query returning the number of rows to be | ||
* expected from the original query, either derived from the query wrapped by this instance or from the information | ||
* passed as arguments. | ||
* | ||
* @param countQueryProjection an optional return type for the query. | ||
* @return a new {@literal DeclaredQuery} instance. | ||
*/ | ||
IntrospectedQuery deriveCountQuery(@Nullable String countQueryProjection); | ||
|
||
String applySorting(Sort sort); | ||
|
||
/** | ||
* @return whether paging is implemented in the query itself, e.g. using SpEL expressions. | ||
* @since 2.0.6 | ||
*/ | ||
default boolean usesPaging() { | ||
return false; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.