forked from spring-projects/spring-data-jpa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor native query handling and JsqlParser usage.
This commit introduce eager alias and projection detection and aims to cache expensive calls. It also revises JPQL parsers and enhancers into single-class hierarchy and removes strange parameter verification (as it was wrong anyway). See: spring-projects#3309 Closes: spring-projects#3311
- Loading branch information
1 parent
3e1c8a2
commit 2dc94dd
Showing
29 changed files
with
685 additions
and
770 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
70 changes: 70 additions & 0 deletions
70
...test/java/org/springframework/data/jpa/repository/query/JSqlParserQueryEnhancerTests.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,70 @@ | ||
/* | ||
* Copyright 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 jmh.mbr.junit5.Microbenchmark; | ||
|
||
import java.io.IOException; | ||
|
||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.annotations.Fork; | ||
import org.openjdk.jmh.annotations.Level; | ||
import org.openjdk.jmh.annotations.Measurement; | ||
import org.openjdk.jmh.annotations.Scope; | ||
import org.openjdk.jmh.annotations.Setup; | ||
import org.openjdk.jmh.annotations.State; | ||
import org.openjdk.jmh.annotations.Timeout; | ||
import org.openjdk.jmh.annotations.Warmup; | ||
|
||
import org.springframework.data.domain.Sort; | ||
|
||
/** | ||
* @author Mark Paluch | ||
*/ | ||
@Microbenchmark | ||
@Fork(1) | ||
@Warmup(time = 2, iterations = 3) | ||
@Measurement(time = 2) | ||
@Timeout(time = 2) | ||
public class JSqlParserQueryEnhancerTests { | ||
|
||
@State(Scope.Benchmark) | ||
public static class BenchmarkParameters { | ||
|
||
JSqlParserQueryEnhancer enhancer; | ||
Sort sort = Sort.by("foo"); | ||
private byte[] serialized; | ||
|
||
@Setup(Level.Iteration) | ||
public void doSetup() throws IOException { | ||
|
||
String s = """ | ||
select SOME_COLUMN from SOME_TABLE where REPORTING_DATE = :REPORTING_DATE | ||
except | ||
select SOME_COLUMN from SOME_OTHER_TABLE where REPORTING_DATE = :REPORTING_DATE | ||
union select SOME_COLUMN from SOME_OTHER_OTHER_TABLE"""; | ||
|
||
enhancer = new JSqlParserQueryEnhancer(DeclaredQuery.of(s, true)); | ||
|
||
} | ||
} | ||
|
||
@Benchmark | ||
public Object applySortWithParsing(BenchmarkParameters p) { | ||
return p.enhancer.applySorting(p.sort); | ||
} | ||
|
||
} |
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
44 changes: 0 additions & 44 deletions
44
...-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/EqlQueryParser.java
This file was deleted.
Oops, something went wrong.
44 changes: 0 additions & 44 deletions
44
...-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/HqlQueryParser.java
This file was deleted.
Oops, something went wrong.
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.