Skip to content

Commit a6f8716

Browse files
committed
Polishing.
Simplify POM setup. Reformat code. See #3745 Original pull request: #3781
1 parent c149e15 commit a6f8716

15 files changed

+64
-223
lines changed

spring-data-jpa/pom.xml

+1-127
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@
343343
<groupId>org.apache.maven.plugins</groupId>
344344
<artifactId>maven-compiler-plugin</artifactId>
345345
<configuration>
346-
<annotationProcessorPaths>
346+
<annotationProcessorPaths combine.children="append">
347347
<path>
348348
<groupId>com.querydsl</groupId>
349349
<artifactId>querydsl-apt</artifactId>
@@ -424,130 +424,4 @@
424424
</plugins>
425425
</build>
426426

427-
<profiles>
428-
<profile>
429-
<id>all-dbs</id>
430-
<build>
431-
<plugins>
432-
<plugin>
433-
<groupId>org.apache.maven.plugins</groupId>
434-
<artifactId>maven-surefire-plugin</artifactId>
435-
<executions>
436-
<execution>
437-
<id>mysql-test</id>
438-
<phase>test</phase>
439-
<goals>
440-
<goal>test</goal>
441-
</goals>
442-
<configuration>
443-
<includes>
444-
<include>**/MySql*IntegrationTests.java</include>
445-
</includes>
446-
</configuration>
447-
</execution>
448-
<execution>
449-
<id>postgres-test</id>
450-
<phase>test</phase>
451-
<goals>
452-
<goal>test</goal>
453-
</goals>
454-
<configuration>
455-
<includes>
456-
<include>**/Postgres*IntegrationTests.java
457-
</include>
458-
</includes>
459-
</configuration>
460-
</execution>
461-
</executions>
462-
</plugin>
463-
</plugins>
464-
</build>
465-
</profile>
466-
</profiles>
467-
468-
<profiles>
469-
<profile>
470-
<id>nullaway</id>
471-
<build>
472-
<plugins>
473-
<plugin>
474-
<groupId>org.apache.maven.plugins</groupId>
475-
<artifactId>maven-compiler-plugin</artifactId>
476-
<configuration>
477-
<annotationProcessorPaths>
478-
<path>
479-
<groupId>com.querydsl</groupId>
480-
<artifactId>querydsl-apt</artifactId>
481-
<version>${querydsl}</version>
482-
<classifier>jakarta</classifier>
483-
</path>
484-
<path>
485-
<groupId>org.hibernate.orm</groupId>
486-
<artifactId>hibernate-jpamodelgen</artifactId>
487-
<version>${hibernate}</version>
488-
</path>
489-
<path>
490-
<groupId>org.hibernate.orm</groupId>
491-
<artifactId>hibernate-core</artifactId>
492-
<version>${hibernate}</version>
493-
</path>
494-
<path>
495-
<groupId>org.openjdk.jmh</groupId>
496-
<artifactId>jmh-generator-annprocess</artifactId>
497-
<version>${jmh}</version>
498-
</path>
499-
<path>
500-
<groupId>jakarta.persistence</groupId>
501-
<artifactId>jakarta.persistence-api</artifactId>
502-
<version>${jakarta-persistence-api}</version>
503-
</path>
504-
<path>
505-
<groupId>com.google.errorprone</groupId>
506-
<artifactId>error_prone_core</artifactId>
507-
<version>${errorprone}</version>
508-
</path>
509-
<path>
510-
<groupId>com.uber.nullaway</groupId>
511-
<artifactId>nullaway</artifactId>
512-
<version>${nullaway}</version>
513-
</path>
514-
</annotationProcessorPaths>
515-
</configuration>
516-
<executions>
517-
<execution>
518-
<id>default-compile</id>
519-
<phase>none</phase>
520-
</execution>
521-
<execution>
522-
<id>default-testCompile</id>
523-
<phase>none</phase>
524-
</execution>
525-
<execution>
526-
<id>java-compile</id>
527-
<phase>compile</phase>
528-
<goals>
529-
<goal>compile</goal>
530-
</goals>
531-
<configuration>
532-
<compilerArgs>
533-
<arg>-XDcompilePolicy=simple</arg>
534-
<arg>--should-stop=ifError=FLOW</arg>
535-
<arg>-Xplugin:ErrorProne -XepDisableAllChecks -Xep:NullAway:ERROR -XepOpt:NullAway:OnlyNullMarked=true -XepOpt:NullAway:TreatGeneratedAsUnannotated=true -XepOpt:NullAway:CustomContractAnnotations=org.springframework.lang.Contract</arg>
536-
</compilerArgs>
537-
</configuration>
538-
</execution>
539-
<execution>
540-
<id>java-test-compile</id>
541-
<phase>test-compile</phase>
542-
<goals>
543-
<goal>testCompile</goal>
544-
</goals>
545-
</execution>
546-
</executions>
547-
</plugin>
548-
</plugins>
549-
</build>
550-
</profile>
551-
</profiles>
552-
553427
</project>

spring-data-jpa/src/main/java/org/springframework/data/jpa/domain/Specification.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
import java.util.Arrays;
2626
import java.util.stream.StreamSupport;
2727

28-
import org.springframework.lang.CheckReturnValue;
29-
3028
import org.jspecify.annotations.Nullable;
29+
30+
import org.springframework.lang.CheckReturnValue;
3131
import org.springframework.lang.Contract;
3232
import org.springframework.util.Assert;
3333

@@ -232,6 +232,6 @@ static <T> Specification<T> anyOf(Iterable<Specification<T>> specifications) {
232232
* @return a {@link Predicate}, may be {@literal null}.
233233
*/
234234
@Nullable
235-
Predicate toPredicate(Root<T> root, @Nullable CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder);
235+
Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder);
236236

237237
}

spring-data-jpa/src/main/java/org/springframework/data/jpa/domain/SpecificationComposition.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static <T> Specification<T> composed(@Nullable Specification<T> lhs, @Nullable S
6161
}
6262

6363
private static <T> @Nullable Predicate toPredicate(@Nullable Specification<T> specification, Root<T> root,
64-
@Nullable CriteriaQuery<?> query, CriteriaBuilder builder) {
64+
CriteriaQuery<?> query, CriteriaBuilder builder) {
6565
return specification == null ? null : specification.toPredicate(root, query, builder);
6666
}
6767

spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/config/JpaRepositoryConfigExtension.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
import java.util.Optional;
3434
import java.util.Set;
3535

36-
import org.springframework.aot.generate.GenerationContext;
37-
3836
import org.jspecify.annotations.Nullable;
37+
38+
import org.springframework.aot.generate.GenerationContext;
3939
import org.springframework.beans.factory.aot.BeanRegistrationAotProcessor;
4040
import org.springframework.beans.factory.config.BeanDefinition;
4141
import org.springframework.beans.factory.support.AbstractBeanDefinition;
@@ -117,7 +117,7 @@ public void postProcess(BeanDefinitionBuilder builder, RepositoryConfigurationSo
117117

118118
Optional<String> transactionManagerRef = source.getAttribute("transactionManagerRef");
119119
builder.addPropertyValue("transactionManager", transactionManagerRef.orElse(DEFAULT_TRANSACTION_MANAGER_BEAN_NAME));
120-
if(entityManagerRefs.containsKey(source)) {
120+
if (entityManagerRefs.containsKey(source)) {
121121
builder.addPropertyReference("entityManager", entityManagerRefs.get(source));
122122
}
123123
builder.addPropertyValue(ESCAPE_CHARACTER_PROPERTY, getEscapeCharacter(source).orElse('\\'));

spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JSqlParserQueryEnhancer.java

+11-10
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import net.sf.jsqlparser.statement.select.SetOperationList;
3939
import net.sf.jsqlparser.statement.select.Values;
4040
import net.sf.jsqlparser.statement.update.Update;
41-
import org.jspecify.annotations.Nullable;
4241

4342
import java.io.ByteArrayInputStream;
4443
import java.io.IOException;
@@ -50,6 +49,8 @@
5049
import java.util.Set;
5150
import java.util.StringJoiner;
5251

52+
import org.jspecify.annotations.Nullable;
53+
5354
import org.springframework.data.domain.Sort;
5455
import org.springframework.util.Assert;
5556
import org.springframework.util.CollectionUtils;
@@ -77,7 +78,7 @@ public class JSqlParserQueryEnhancer implements QueryEnhancer {
7778
private final String projection;
7879
private final Set<String> joinAliases;
7980
private final Set<String> selectAliases;
80-
private final byte @Nullable[] serialized;
81+
private final byte @Nullable [] serialized;
8182

8283
/**
8384
* @param query the query we want to enhance. Must not be {@literal null}.
@@ -94,7 +95,7 @@ public JSqlParserQueryEnhancer(DeclaredQuery query) {
9495
this.selectAliases = Collections.unmodifiableSet(getSelectionAliases(this.statement));
9596
this.joinAliases = Collections.unmodifiableSet(getJoinAliases(this.statement));
9697
byte[] tmp = SerializationUtils.serialize(this.statement);
97-
// this.serialized = tmp != null ? tmp : new byte[0];
98+
// this.serialized = tmp != null ? tmp : new byte[0];
9899
this.serialized = SerializationUtils.serialize(this.statement);
99100
}
100101

@@ -331,7 +332,7 @@ private String applySorting(@Nullable Select selectStatement, Sort sort, @Nullab
331332
}
332333

333334
if (!(selectStatement instanceof PlainSelect selectBody)) {
334-
if(selectStatement != null) {
335+
if (selectStatement != null) {
335336
return selectStatement.toString();
336337
} else {
337338
throw new IllegalArgumentException("Select must not be null");
@@ -372,8 +373,8 @@ public String createCountQueryFor(@Nullable String countProjection) {
372373
return createCountQueryFor(selectBody, countProjection, primaryAlias);
373374
}
374375

375-
private static String createCountQueryFor(PlainSelect selectBody,
376-
@Nullable String countProjection, @Nullable String primaryAlias) {
376+
private static String createCountQueryFor(PlainSelect selectBody, @Nullable String countProjection,
377+
@Nullable String primaryAlias) {
377378

378379
// remove order by
379380
selectBody.setOrderByElements(null);
@@ -526,8 +527,8 @@ enum ParsedType {
526527
* @param bytes a serialized object
527528
* @return the result of deserializing the bytes
528529
*/
529-
private static @Nullable Object deserialize(byte @Nullable[] bytes) {
530-
if(ObjectUtils.isEmpty(bytes)) {
530+
private static @Nullable Object deserialize(byte @Nullable [] bytes) {
531+
if (ObjectUtils.isEmpty(bytes)) {
531532
return null;
532533
}
533534
try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bytes))) {
@@ -539,9 +540,9 @@ enum ParsedType {
539540
}
540541
}
541542

542-
private static <T> T deserializeRequired(byte @Nullable[] bytes, Class<T> type) {
543+
private static <T> T deserializeRequired(byte @Nullable [] bytes, Class<T> type) {
543544
Object deserialize = deserialize(bytes);
544-
if(deserialize != null) {
545+
if (deserialize != null) {
545546
return type.cast(deserialize);
546547
}
547548
throw new IllegalStateException("Failed to deserialize object type");

spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpqlCountQueryTransformer.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
import static org.springframework.data.jpa.repository.query.QueryTokens.*;
1919

20-
import org.springframework.data.jpa.repository.query.QueryRenderer.QueryRendererBuilder;
21-
2220
import org.jspecify.annotations.Nullable;
21+
22+
import org.springframework.data.jpa.repository.query.QueryRenderer.QueryRendererBuilder;
2323
import org.springframework.data.jpa.repository.query.QueryTransformers.CountSelectionTokenStream;
2424
import org.springframework.util.StringUtils;
2525

@@ -82,7 +82,7 @@ public QueryRendererBuilder visitSelect_clause(JpqlParser.Select_clauseContext c
8282
if (usesDistinct) {
8383
nested.append(QueryTokens.expression(ctx.DISTINCT()));
8484
nested.append(getDistinctCountSelection(QueryTokenStream.concat(ctx.select_item(), this::visit, TOKEN_COMMA)));
85-
} else if(StringUtils.hasText(primaryFromAlias)) {
85+
} else if (StringUtils.hasText(primaryFromAlias)) {
8686
nested.append(QueryTokens.token(primaryFromAlias));
8787
} else {
8888
throw new IllegalStateException("No primary alias present");

spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpqlUtils.java

+13-10
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,25 @@
2525

2626
import java.util.Objects;
2727

28-
import org.springframework.data.mapping.PropertyPath;
29-
3028
import org.jspecify.annotations.Nullable;
29+
30+
import org.springframework.data.mapping.PropertyPath;
3131
import org.springframework.util.StringUtils;
3232

3333
/**
34+
* Utilities to create JPQL expressions, derived from {@link QueryUtils}.
35+
*
3436
* @author Mark Paluch
3537
*/
3638
class JpqlUtils {
3739

38-
static JpqlQueryBuilder.PathExpression toExpressionRecursively(@Nullable Metamodel metamodel, JpqlQueryBuilder.Origin source,
39-
Bindable<?> from, PropertyPath property) {
40+
static JpqlQueryBuilder.PathExpression toExpressionRecursively(@Nullable Metamodel metamodel,
41+
JpqlQueryBuilder.Origin source, Bindable<?> from, PropertyPath property) {
4042
return toExpressionRecursively(metamodel, source, from, property, false);
4143
}
4244

43-
static JpqlQueryBuilder.PathExpression toExpressionRecursively(@Nullable Metamodel metamodel, JpqlQueryBuilder.Origin source,
44-
Bindable<?> from, PropertyPath property, boolean isForSelection) {
45+
static JpqlQueryBuilder.PathExpression toExpressionRecursively(@Nullable Metamodel metamodel,
46+
JpqlQueryBuilder.Origin source, Bindable<?> from, PropertyPath property, boolean isForSelection) {
4547
return toExpressionRecursively(metamodel, source, from, property, isForSelection, false);
4648
}
4749

@@ -54,8 +56,9 @@ static JpqlQueryBuilder.PathExpression toExpressionRecursively(@Nullable Metamod
5456
* @param hasRequiredOuterJoin has a parent already required an outer join?
5557
* @return the expression
5658
*/
57-
static JpqlQueryBuilder.PathExpression toExpressionRecursively(@Nullable Metamodel metamodel, JpqlQueryBuilder.Origin source,
58-
Bindable<?> from, PropertyPath property, boolean isForSelection, boolean hasRequiredOuterJoin) {
59+
static JpqlQueryBuilder.PathExpression toExpressionRecursively(@Nullable Metamodel metamodel,
60+
JpqlQueryBuilder.Origin source, Bindable<?> from, PropertyPath property, boolean isForSelection,
61+
boolean hasRequiredOuterJoin) {
5962

6063
String segment = property.getSegment();
6164

@@ -81,7 +84,7 @@ static JpqlQueryBuilder.PathExpression toExpressionRecursively(@Nullable Metamod
8184
ManagedType<?> managedTypeForModel = QueryUtils.getManagedTypeForModel(from);
8285
Attribute<?, ?> nextAttribute = getModelForPath(metamodel, property, managedTypeForModel, from);
8386

84-
if(nextAttribute == null) {
87+
if (nextAttribute == null) {
8588
throw new IllegalStateException("Binding property is null");
8689
}
8790

@@ -144,7 +147,7 @@ static boolean requiresOuterJoin(@Nullable Metamodel metamodel, Bindable<?> bind
144147
}
145148
}
146149

147-
if(metamodel != null) {
150+
if (metamodel != null) {
148151

149152
Class<?> fallbackType = fallback.getBindableJavaType();
150153
try {

0 commit comments

Comments
 (0)