diff --git a/config/accepted-api-changes.json b/config/accepted-api-changes.json index 0d4f101c7a3..1948e84d4be 100644 --- a/config/accepted-api-changes.json +++ b/config/accepted-api-changes.json @@ -1,2 +1,27 @@ [ + { + "type": "io.micronaut.data.processor.visitors.finders.AbstractPatternMethodMatcher", + "member": "Field patternWithBySyntax", + "reason": "Removed deprecated code for Micronaut Framework 5." + }, + { + "type": "io.micronaut.data.processor.visitors.finders.AbstractPatternMethodMatcher", + "member": "Field patternWithoutBySyntax", + "reason": "Removed deprecated code for Micronaut Framework 5." + }, + { + "type": "io.micronaut.data.processor.visitors.finders.AbstractPatternMethodMatcher", + "member": "Constructor io.micronaut.data.processor.visitors.finders.AbstractPatternMethodMatcher(boolean,java.lang.String[])", + "reason": "Removed deprecated code for Micronaut Framework 5." + }, + { + "type": "io.micronaut.data.processor.visitors.finders.AbstractPatternMethodMatcher", + "member": "Implemented interface io.micronaut.data.processor.visitors.finders.MethodMatcher", + "reason": "Removed deprecated code for Micronaut Framework 5." + }, + { + "type": "io.micronaut.data.processor.visitors.finders.AbstractPatternMethodMatcher", + "member": "Implemented interface io.micronaut.core.order.Ordered", + "reason": "Removed deprecated code for Micronaut Framework 5." + } ] diff --git a/data-hibernate-jpa/src/test/java/io/micronaut/data/hibernate/BookRepository.java b/data-hibernate-jpa/src/test/java/io/micronaut/data/hibernate/BookRepository.java index 7c9cc476126..e23d8fefbbf 100644 --- a/data-hibernate-jpa/src/test/java/io/micronaut/data/hibernate/BookRepository.java +++ b/data-hibernate-jpa/src/test/java/io/micronaut/data/hibernate/BookRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2020 original authors + * Copyright 2017-2024 original authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,20 +17,17 @@ import io.micronaut.core.annotation.Nullable; import io.micronaut.data.annotation.Id; -import io.micronaut.data.annotation.Join; import io.micronaut.data.annotation.ParameterExpression; import io.micronaut.data.annotation.Query; import io.micronaut.data.annotation.Repository; import io.micronaut.data.annotation.Where; import io.micronaut.data.jpa.annotation.EntityGraph; import io.micronaut.data.jpa.repository.JpaSpecificationExecutor; -import io.micronaut.data.model.Page; -import io.micronaut.data.model.Pageable; import io.micronaut.data.tck.entities.Author; import io.micronaut.data.tck.entities.Book; import io.micronaut.data.tck.repositories.AuthorRepository; - import jakarta.transaction.Transactional; + import java.util.Collection; import java.util.List; @@ -41,22 +38,6 @@ public BookRepository(AuthorRepository authorRepository) { super(authorRepository); } - /** - * @deprecated Order by 'author.name' case without a join. Hibernate will do the cross join if the association property is accessed by the property path without join. - */ - @Override - @Query(value = "SELECT book_ FROM Book book_", countQuery = "SELECT count(book_) FROM Book book_ ") - @Join(value = "author", type = Join.Type.FETCH) - @Deprecated - public abstract Page listPageableCustomQuery(Pageable pageable); - - /** - * @deprecated Order by 'author.name' case without a join. Hibernate will do the cross join if the association property is accessed by the property path without join. - */ - @Query(value = "SELECT book_ FROM Book book_", countQuery = "SELECT count(book_) FROM Book book_ ") - @Deprecated - public abstract Page listPageableCustomQuery2(Pageable pageable); - @EntityGraph( attributePaths = { "totalPages", diff --git a/data-model/src/main/java/io/micronaut/data/intercept/annotation/DataMethod.java b/data-model/src/main/java/io/micronaut/data/intercept/annotation/DataMethod.java index 75cb3755e80..dc22d33b5a4 100644 --- a/data-model/src/main/java/io/micronaut/data/intercept/annotation/DataMethod.java +++ b/data-model/src/main/java/io/micronaut/data/intercept/annotation/DataMethod.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2020 original authors + * Copyright 2017-2024 original authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,17 +15,16 @@ */ package io.micronaut.data.intercept.annotation; -import io.micronaut.context.annotation.Property; import io.micronaut.core.annotation.Internal; import io.micronaut.data.intercept.DataInterceptor; import io.micronaut.data.model.DataType; import java.io.Serializable; import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import java.lang.annotation.Inherited; /** * Internal annotation used to configure execution handling for io.micronaut.data.runtime.intercept.DataIntroductionAdvice. @@ -84,41 +83,6 @@ */ String META_MEMBER_INTERCEPTOR = "interceptor"; - /** - * The member name that holds parameter binding. - * @deprecated No longer used - */ - @Deprecated(forRemoval = true) - String META_MEMBER_PARAMETER_BINDING = "parameterBinding"; - - /** - * The member name that holds parameter binding paths. - * @deprecated No longer used - */ - @Deprecated(forRemoval = true) - String META_MEMBER_PARAMETER_BINDING_PATHS = META_MEMBER_PARAMETER_BINDING + "Paths"; - - /** - * The member name that holds parameter auto-populated property paths. - * @deprecated No longer used - */ - @Deprecated(forRemoval = true) - String META_MEMBER_PARAMETER_AUTO_POPULATED_PROPERTY_PATHS = META_MEMBER_PARAMETER_BINDING + "AutoPopulatedPaths"; - - /** - * The member name that holds parameter auto-populated property paths. - * @deprecated No longer used - */ - @Deprecated(forRemoval = true) - String META_MEMBER_PARAMETER_AUTO_POPULATED_PREVIOUS_PROPERTY_PATHS = META_MEMBER_PARAMETER_BINDING + "AutoPopulatedPreviousPaths"; - - /** - * The member name that holds parameter auto-populated property paths. - * @deprecated No longer used - */ - @Deprecated(forRemoval = true) - String META_MEMBER_PARAMETER_AUTO_POPULATED_PREVIOUS_PROPERTY_INDEXES = META_MEMBER_PARAMETER_BINDING + "AutoPopulatedPrevious"; - /** * The ID type. */ @@ -169,20 +133,6 @@ */ String META_MEMBER_RAW_COUNT_QUERY = "rawCountQuery"; - /** - * Meta member for storing the parameter type defs. - * @deprecated No longer used - */ - @Deprecated(forRemoval = true) - String META_MEMBER_PARAMETER_TYPE_DEFS = "parameterTypeDefs"; - - /** - * Meta member for storing the parameter converters. - * @deprecated No longer used - */ - @Deprecated(forRemoval = true) - String META_MEMBER_PARAMETER_CONVERTERS = "parameterConverters"; - /** * Meta member for storing the parameters. */ @@ -224,17 +174,6 @@ */ Class idType() default Serializable.class; - /** - * The parameter binding defines which method arguments bind to which - * query parameters. The {@link Property#name()} is used to define the query parameter name and the - * {@link Property#value()} is used to define method argument name to bind. - * - * @return The parameter binding. - * @deprecated No longer used - */ - @Deprecated(forRemoval = true) - Property[] parameterBinding() default {}; - /** * The argument that defines the pageable object. * diff --git a/data-model/src/main/java/io/micronaut/data/model/PersistentProperty.java b/data-model/src/main/java/io/micronaut/data/model/PersistentProperty.java index 047d6c2927c..3ad173ca837 100644 --- a/data-model/src/main/java/io/micronaut/data/model/PersistentProperty.java +++ b/data-model/src/main/java/io/micronaut/data/model/PersistentProperty.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2020 original authors + * Copyright 2017-2024 original authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,8 +15,8 @@ */ package io.micronaut.data.model; -import io.micronaut.core.annotation.NonNull; import io.micronaut.core.annotation.AnnotationMetadata; +import io.micronaut.core.annotation.NonNull; import io.micronaut.core.annotation.Nullable; import io.micronaut.core.naming.NameUtils; import io.micronaut.data.annotation.AutoPopulated; @@ -42,16 +42,6 @@ public interface PersistentProperty extends PersistentElement { @Override @NonNull String getName(); - /** - * The name with the first letter in upper case as per Java bean conventions. - * @return The capitilized name - * @deprecated The method with a type replaced with {@link #getCapitalizedName()}. - */ - @Deprecated(forRemoval = true) - default @NonNull String getCapitilizedName() { - return NameUtils.capitalize(getName()); - } - /** * The name with the first letter in upper case as per Java bean conventions. * @return The capitalized name diff --git a/data-model/src/main/java/io/micronaut/data/model/query/builder/AbstractSqlLikeQueryBuilder.java b/data-model/src/main/java/io/micronaut/data/model/query/builder/AbstractSqlLikeQueryBuilder.java index 5fd6a15147e..e5b9b34f40c 100644 --- a/data-model/src/main/java/io/micronaut/data/model/query/builder/AbstractSqlLikeQueryBuilder.java +++ b/data-model/src/main/java/io/micronaut/data/model/query/builder/AbstractSqlLikeQueryBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2020 original authors + * Copyright 2017-2024 original authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1927,23 +1927,6 @@ public QueryResult buildOrderBy(@NonNull PersistentEntity entity, @NonNull Sort return buildOrderBy("", entity, AnnotationMetadata.EMPTY_METADATA, sort, false); } - /** - * Encode the given query into the encoded query instance. - * - * @param query The query - * @param entity The root entity - * @param annotationMetadata The annotation metadata - * @param sort The sort - * @return The encoded query - * - * @deprecated use {@link #buildOrderBy(String, PersistentEntity, AnnotationMetadata, Sort, boolean)} - */ - @NonNull - @Deprecated(forRemoval = true, since = "4.2.0") - public QueryResult buildOrderBy(String query, @NonNull PersistentEntity entity, @NonNull AnnotationMetadata annotationMetadata, @NonNull Sort sort) { - return buildOrderBy(query, entity, annotationMetadata, sort, false); - } - /** * Encode the given query into the encoded query instance. * diff --git a/data-model/src/main/java/io/micronaut/data/model/runtime/StoredQuery.java b/data-model/src/main/java/io/micronaut/data/model/runtime/StoredQuery.java index cb2d6147dec..1f6e05996fd 100644 --- a/data-model/src/main/java/io/micronaut/data/model/runtime/StoredQuery.java +++ b/data-model/src/main/java/io/micronaut/data/model/runtime/StoredQuery.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2020 original authors + * Copyright 2017-2024 original authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,6 @@ import io.micronaut.core.annotation.Experimental; import io.micronaut.core.annotation.NonNull; import io.micronaut.core.naming.Named; -import io.micronaut.core.reflect.ReflectionUtils; import io.micronaut.core.type.Argument; import io.micronaut.data.model.DataType; import io.micronaut.data.model.query.JoinPath; @@ -27,7 +26,6 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.Set; /** @@ -127,14 +125,6 @@ default boolean isProcedure() { */ OperationType getOperationType(); - /** - * Are the placeholders for query set using numeric indices starting from 1. - * @return True if they are. - * @deprecated Not used anymore - */ - @Deprecated(forRemoval = true) - boolean useNumericPlaceholders(); - /** * Returns whether the query returns the actual entity or a Data Transfer Object (DTO) project. Defaults to false. * @@ -144,29 +134,6 @@ default boolean isDtoProjection() { return false; } - /** - * The type of the ID member of the entity. - * - * @return The ID type - * @deprecated Not used anymore - */ - @Deprecated(forRemoval = true) - default Optional> getEntityIdentifierType() { - return Optional.empty(); - } - - /** - * The argument types to the method that invokes the query. - * - * @return The argument types - * @deprecated Not used anymore - */ - @Deprecated(forRemoval = true) - @NonNull - default Class[] getArgumentTypes() { - return ReflectionUtils.EMPTY_CLASS_ARRAY; - } - /** * @return Is this a count query. */ @@ -189,14 +156,6 @@ default Map getQueryHints() { return Collections.emptySet(); } - /** - * Whether the query can be treated as a single result. - * @return True if it can. - * @deprecated Not used anymore - */ - @Deprecated(forRemoval = true) - boolean isSingleResult(); - /** * @return Whether a result consumer is present */ diff --git a/data-processor/src/main/java/io/micronaut/data/processor/visitors/finders/AbstractPatternMethodMatcher.java b/data-processor/src/main/java/io/micronaut/data/processor/visitors/finders/AbstractPatternMethodMatcher.java deleted file mode 100644 index 1be211dfb79..00000000000 --- a/data-processor/src/main/java/io/micronaut/data/processor/visitors/finders/AbstractPatternMethodMatcher.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2017-2021 original 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 io.micronaut.data.processor.visitors.finders; - -import io.micronaut.core.annotation.Experimental; -import io.micronaut.core.annotation.NonNull; -import io.micronaut.core.util.ArrayUtils; -import io.micronaut.data.processor.visitors.MethodMatchContext; - -import java.util.Arrays; -import java.util.Comparator; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; - -/** - * Abstract pattern method match that support two variations of method names. - * - * - With `by` syntax - projection followed by predicates - * - Without `by` syntax - predicates only - * - * @author Denis Stepanov - * @since 3.2 - * @deprecated No longer used - */ -@Deprecated(forRemoval = true) -@Experimental -public abstract class AbstractPatternMethodMatcher implements MethodMatcher { - - protected final Pattern patternWithBySyntax; - protected final Pattern patternWithoutBySyntax; - - /** - * Default constructor. - * - * @param supportsProjections true of matcher supports projections - * @param prefixes The prefixes - */ - protected AbstractPatternMethodMatcher(boolean supportsProjections, @NonNull String... prefixes) { - if (ArrayUtils.isEmpty(prefixes)) { - throw new IllegalArgumentException("At least one prefix required"); - } - Arrays.sort(prefixes, Comparator.comparingInt(String::length).thenComparing(String::compareTo).reversed()); - this.patternWithBySyntax = compileWithProjectionSyntax(supportsProjections, prefixes); - this.patternWithoutBySyntax = computeWithoutProjectionSyntax(prefixes); - } - - @Override - public final MethodMatch match(MethodMatchContext matchContext) { - String methodName = matchContext.getMethodElement().getName(); - Matcher matcher = patternWithBySyntax.matcher(methodName); - if (matcher.find()) { - return match(matchContext, matcher); - } - matcher = patternWithoutBySyntax.matcher(methodName); - if (matcher.find()) { - return match(matchContext, matcher); - } - return null; - } - - /** - * Handle match. - * - * @param matchContext The match context - * @param matcher The matcher - * @return The method match - */ - protected abstract MethodMatch match(MethodMatchContext matchContext, Matcher matcher); - - private static Pattern computeWithoutProjectionSyntax(String[] prefixes) { - String prefixPattern = String.join("|", prefixes); - return Pattern.compile("^((" + prefixPattern + ")(\\S*?))$"); - } - - private static Pattern compileWithProjectionSyntax(boolean supportsProjections, String[] prefixes) { - String patternStr; - if (supportsProjections) { - String prefixPattern = String.join("|", prefixes); - patternStr = "((" + prefixPattern + ")([\\w\\d]*?)By)([A-Z]\\w*)"; - } else { - String prefixPattern = Arrays.stream(prefixes).map(p -> p + "By").collect(Collectors.joining("|")); - patternStr = "((" + prefixPattern + "))([A-Z]\\w*)"; - } - return Pattern.compile(patternStr); - } - -} diff --git a/data-runtime/src/main/java/io/micronaut/data/runtime/mapper/sql/SqlDTOMapper.java b/data-runtime/src/main/java/io/micronaut/data/runtime/mapper/sql/SqlDTOMapper.java deleted file mode 100644 index 61c569a4872..00000000000 --- a/data-runtime/src/main/java/io/micronaut/data/runtime/mapper/sql/SqlDTOMapper.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2017-2020 original 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 io.micronaut.data.runtime.mapper.sql; - -import io.micronaut.data.model.runtime.RuntimePersistentEntity; -import io.micronaut.data.runtime.convert.DataConversionService; -import io.micronaut.data.runtime.mapper.DTOMapper; -import io.micronaut.data.runtime.mapper.ResultReader; - -/** - * Subclass of {@link DTOMapper} specifically for SQL. - * - * @param The entity type - * @param The source type. - * @param The result type - * @deprecated Not used as of 4.2 - */ -@Deprecated(forRemoval = true, since = "4.2") -public class SqlDTOMapper extends DTOMapper implements SqlTypeMapper { - /** - * Default constructor. - * - * @param persistentEntity The entity - * @param resultReader The result reader - * @param conversionService The conversion service - */ - public SqlDTOMapper(RuntimePersistentEntity persistentEntity, - ResultReader resultReader, - DataConversionService conversionService) { - this(persistentEntity, resultReader, null, conversionService); - } - - /** - * Default constructor. - * - * @param persistentEntity The entity - * @param resultReader The result reader - * @param jsonColumnReader The json column reader - * @param conversionService The conversion service - */ - public SqlDTOMapper(RuntimePersistentEntity persistentEntity, - ResultReader resultReader, - SqlJsonColumnReader jsonColumnReader, - DataConversionService conversionService) { - super(persistentEntity, resultReader, jsonColumnReader, conversionService); - } - - /** - * Default constructor. - * - * @param persistentEntity The entity - * @param dtoEntity The DTO entity - * @param resultReader The result reader - * @param jsonColumnReader The json column reader - * @param conversionService The conversion service - */ - public SqlDTOMapper(RuntimePersistentEntity persistentEntity, - RuntimePersistentEntity dtoEntity, - ResultReader resultReader, - SqlJsonColumnReader jsonColumnReader, - DataConversionService conversionService) { - super(persistentEntity, dtoEntity, resultReader, jsonColumnReader, conversionService); - } - - @Override - public boolean hasNext(S resultSet) { - return getResultReader().next(resultSet); - } -} diff --git a/data-runtime/src/main/java/io/micronaut/data/runtime/query/DefaultStoredQueryResolver.java b/data-runtime/src/main/java/io/micronaut/data/runtime/query/DefaultStoredQueryResolver.java index f08b306e565..3e9866ccadc 100644 --- a/data-runtime/src/main/java/io/micronaut/data/runtime/query/DefaultStoredQueryResolver.java +++ b/data-runtime/src/main/java/io/micronaut/data/runtime/query/DefaultStoredQueryResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2022 original authors + * Copyright 2017-2024 original authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,10 +21,8 @@ import io.micronaut.core.type.Argument; import io.micronaut.data.annotation.DataAnnotationUtils; import io.micronaut.data.annotation.Query; -import io.micronaut.data.annotation.RepositoryConfiguration; import io.micronaut.data.intercept.annotation.DataMethod; import io.micronaut.data.model.DataType; -import io.micronaut.data.model.query.builder.sql.SqlQueryBuilder; import io.micronaut.data.model.runtime.QueryParameterBinding; import io.micronaut.data.model.runtime.StoredQuery; import io.micronaut.data.operations.HintsCapableRepository; @@ -33,7 +31,7 @@ import java.util.List; -import static io.micronaut.data.model.runtime.StoredQuery.*; +import static io.micronaut.data.model.runtime.StoredQuery.OperationType; /** * Default stored query resolver. @@ -144,22 +142,11 @@ public DataType getResultDataType() { return DataType.ENTITY; } - @Override - public boolean useNumericPlaceholders() { - return annotationMetadata.classValue(RepositoryConfiguration.class, "queryBuilder") - .map(c -> c == SqlQueryBuilder.class).orElse(false); - } - @Override public boolean isCount() { return false; } - @Override - public boolean isSingleResult() { - return isSingleResult; - } - @Override public boolean hasResultConsumer() { return false; @@ -243,23 +230,11 @@ public DataType getResultDataType() { return DataType.LONG; } - @Override - public boolean useNumericPlaceholders() { - return annotationMetadata - .classValue(RepositoryConfiguration.class, "queryBuilder") - .map(c -> c == SqlQueryBuilder.class).orElse(false); - } - @Override public boolean isCount() { return true; } - @Override - public boolean isSingleResult() { - return true; - } - @Override public boolean hasResultConsumer() { return false; diff --git a/data-runtime/src/main/java/io/micronaut/data/runtime/query/internal/BasicStoredQuery.java b/data-runtime/src/main/java/io/micronaut/data/runtime/query/internal/BasicStoredQuery.java index ccdedb6c39f..587c8e8c602 100644 --- a/data-runtime/src/main/java/io/micronaut/data/runtime/query/internal/BasicStoredQuery.java +++ b/data-runtime/src/main/java/io/micronaut/data/runtime/query/internal/BasicStoredQuery.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2022 original authors + * Copyright 2017-2024 original authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,10 +19,8 @@ import io.micronaut.core.annotation.Internal; import io.micronaut.core.type.Argument; import io.micronaut.data.annotation.Query; -import io.micronaut.data.annotation.RepositoryConfiguration; import io.micronaut.data.intercept.annotation.DataMethod; import io.micronaut.data.model.DataType; -import io.micronaut.data.model.query.builder.sql.SqlQueryBuilder; import io.micronaut.data.model.runtime.QueryParameterBinding; import io.micronaut.data.model.runtime.StoredQuery; @@ -143,22 +141,11 @@ public List getQueryBindings() { return queryParameterBindings; } - @Override - public boolean useNumericPlaceholders() { - return annotationMetadata.classValue(RepositoryConfiguration.class, "queryBuilder") - .map(c -> c == SqlQueryBuilder.class).orElse(false); - } - @Override public boolean isCount() { return isCount; } - @Override - public boolean isSingleResult() { - return isSingleResult; - } - @Override public boolean hasResultConsumer() { return false; diff --git a/data-runtime/src/main/java/io/micronaut/data/runtime/query/internal/DefaultStoredQuery.java b/data-runtime/src/main/java/io/micronaut/data/runtime/query/internal/DefaultStoredQuery.java index dcecbdf48ff..4f59fd36068 100644 --- a/data-runtime/src/main/java/io/micronaut/data/runtime/query/internal/DefaultStoredQuery.java +++ b/data-runtime/src/main/java/io/micronaut/data/runtime/query/internal/DefaultStoredQuery.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2022 original authors + * Copyright 2017-2024 original authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,12 @@ import io.micronaut.core.reflect.ReflectionUtils; import io.micronaut.core.util.ArrayUtils; import io.micronaut.core.util.StringUtils; -import io.micronaut.data.annotation.*; +import io.micronaut.data.annotation.DataAnnotationUtils; +import io.micronaut.data.annotation.ParameterExpression; +import io.micronaut.data.annotation.Query; +import io.micronaut.data.annotation.QueryHint; +import io.micronaut.data.annotation.RepositoryConfiguration; +import io.micronaut.data.annotation.TypeRole; import io.micronaut.data.intercept.annotation.DataMethod; import io.micronaut.data.intercept.annotation.DataMethodQueryParameter; import io.micronaut.data.model.AssociationUtils; @@ -223,11 +228,6 @@ public Set getJoinFetchPaths() { return method; } - @Override - public boolean isSingleResult() { - return !isCount() && getJoinFetchPaths().isEmpty(); - } - @Override public boolean hasResultConsumer() { return this.hasResultConsumer; @@ -262,16 +262,6 @@ public OperationType getOperationType() { return operationType; } - /** - * Is this a raw SQL query. - * - * @return The raw sql query. - */ - @Override - public boolean useNumericPlaceholders() { - return isNumericPlaceHolder; - } - /** * @return Whether the query is a DTO query */ @@ -299,16 +289,6 @@ public DataType getResultDataType() { .orElse(DataType.OBJECT); } - /** - * @return The ID type - */ - @SuppressWarnings("unchecked") - @Override - public Optional> getEntityIdentifierType() { - Optional o = annotationMetadata.classValue(DATA_METHOD_ANN_NAME, DataMethod.META_MEMBER_ID_TYPE); - return o; - } - /** * @return The root entity type */ @@ -340,12 +320,6 @@ public String getName() { return method.getMethodName(); } - @Override - @NonNull - public Class[] getArgumentTypes() { - return method.getArgumentTypes(); - } - @Override public boolean isOptimisticLock() { return isOptimisticLock; diff --git a/data-runtime/src/main/java/io/micronaut/data/runtime/query/internal/DelegateStoredQuery.java b/data-runtime/src/main/java/io/micronaut/data/runtime/query/internal/DelegateStoredQuery.java index f132cec3b3c..11f4eb3f94f 100644 --- a/data-runtime/src/main/java/io/micronaut/data/runtime/query/internal/DelegateStoredQuery.java +++ b/data-runtime/src/main/java/io/micronaut/data/runtime/query/internal/DelegateStoredQuery.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2022 original authors + * Copyright 2017-2024 original authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,6 @@ import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.Set; /** @@ -103,26 +102,11 @@ default OperationType getOperationType() { return getStoredQueryDelegate().getOperationType(); } - @Override - default boolean useNumericPlaceholders() { - return getStoredQueryDelegate().useNumericPlaceholders(); - } - @Override default boolean isDtoProjection() { return getStoredQueryDelegate().isDtoProjection(); } - @Override - default Optional> getEntityIdentifierType() { - return getStoredQueryDelegate().getEntityIdentifierType(); - } - - @Override - default Class[] getArgumentTypes() { - return getStoredQueryDelegate().getArgumentTypes(); - } - @Override default boolean isCount() { return getStoredQueryDelegate().isCount(); @@ -138,11 +122,6 @@ default Set getJoinFetchPaths() { return getStoredQueryDelegate().getJoinFetchPaths(); } - @Override - default boolean isSingleResult() { - return getStoredQueryDelegate().isSingleResult(); - } - @Override default boolean hasResultConsumer() { return getStoredQueryDelegate().hasResultConsumer(); diff --git a/data-tx/src/main/java/io/micronaut/transaction/support/AbstractDataSourceTransactionManagerCondition.java b/data-tx/src/main/java/io/micronaut/transaction/support/AbstractDataSourceTransactionManagerCondition.java index 14159647e8b..3660e63e235 100644 --- a/data-tx/src/main/java/io/micronaut/transaction/support/AbstractDataSourceTransactionManagerCondition.java +++ b/data-tx/src/main/java/io/micronaut/transaction/support/AbstractDataSourceTransactionManagerCondition.java @@ -50,6 +50,7 @@ public boolean matches(ConditionContext context) { dataSourceName = "default"; } } + // and do what now? transactionManagerProperty(ConditionContext, String) deprecated and removed return transactionManagerProperty(context, dataSourceName) .map(name -> name.equals(getTransactionManagerName())) .orElse(true); diff --git a/src/main/docs/guide/breaks.adoc b/src/main/docs/guide/breaks.adoc index 77116fcf433..918957851fc 100644 --- a/src/main/docs/guide/breaks.adoc +++ b/src/main/docs/guide/breaks.adoc @@ -1,6 +1,36 @@ -This section documents breaking changes between Micronaut versions +This section documents breaking changes between Micronaut Data versions: -== 4.0.0 +== Micronaut Data 5.0.0 + +=== Deprecations + +- Several members of the annotation `io.micronaut.data.intercept.annotation.DataMethod` deprecated previously have been removed. +`@DataMethod` is an internal annotation and the removed members are no longer used. + +- The interface method `io.micronaut.data.model.PersistentProperty.getCapitilizedName()` deprecated previously has been removed. +It is replaced by `getCapitalizedName()`. + +- The method `io.micronaut.data.model.query.builder.AbstractSqlLikeQueryBuilder.buildOrderBy(String, PersistentEntity, AnnotationMetadata, Sort)` deprecated previously has been removed. +Use `buildOrderBy(String, PersistentEntity, AnnotationMetadata, Sort, boolean)` instead. + +- The following interface methods of `io.micronaut.data.model.runtime.StoredQuery` deprecated previously have been removed. They are no longer used. +** `boolean useNumericPlaceholders()` +** `Optional> getEntityIdentifierType()` +** `Class[] getArgumentTypes()` +** `boolean isSingleResult()` +- As a consequence of the `StoredQuery` method removals, the following types that were overriding these methods have been changed to remove their implementations: +** Internal class `io.micronaut.data.runtime.query.internal.BasicStoredQuery` +** Internal class `io.micronaut.data.runtime.query.internal.DefaultStoredQuery` +** Interface `io.micronaut.data.runtime.query.internal.DelegateStoredQuery` +** Anonymous inner class of `io.micronaut.data.runtime.query.DefaultStoredQueryResolver` + +- The following classes, deprecated previously have been removed. They are no longer used. +** `io.micronaut.data.processor.visitors.finders.AbstractPatternMethodMatcher` +** `io.micronaut.data.runtime.mapper.sql.SqlDTOMapper` + +- TODO: document `io.micronaut.transaction.support.AbstractDataSourceTransactionManagerCondition.transactionManagerProperty(ConditionContext, String)` deprecation and removal. + +== Micronaut Data 4.0.0 === Repositories validation