From eb9e70e30d43523ed7da81debfcf902a7b6f918d Mon Sep 17 00:00:00 2001 From: Gavin King Date: Sat, 22 Jan 2022 10:06:27 +0100 Subject: [PATCH] fix some minor generics issues --- .../hibernate/cache/spi/QueryResultsCache.java | 6 +++--- .../hibernate/query/CommonQueryContract.java | 6 +++--- .../java/org/hibernate/query/MutationQuery.java | 4 ++-- .../org/hibernate/query/SelectionQuery.java | 2 +- .../query/spi/DelegatingQueryOptions.java | 4 ++-- .../org/hibernate/query/spi/QueryOptions.java | 13 ++++--------- .../internal/ConcreteSqmSelectQueryPlan.java | 6 +++++- .../JdbcSelectExecutorStandardImpl.java | 17 +++++++++-------- .../jdbc/internal/JdbcValuesCacheHit.java | 4 ++-- 9 files changed, 31 insertions(+), 31 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/cache/spi/QueryResultsCache.java b/hibernate-core/src/main/java/org/hibernate/cache/spi/QueryResultsCache.java index c8c19e4b7b..4af1e8f680 100644 --- a/hibernate-core/src/main/java/org/hibernate/cache/spi/QueryResultsCache.java +++ b/hibernate-core/src/main/java/org/hibernate/cache/spi/QueryResultsCache.java @@ -39,7 +39,7 @@ public interface QueryResultsCache { */ boolean put( QueryKey key, - List result, + List result, SharedSessionContractImplementor session) throws HibernateException; /** @@ -53,7 +53,7 @@ public interface QueryResultsCache { * * @throws HibernateException Indicates a problem delegating to the underlying cache. */ - List get( + List get( QueryKey key, Set spaces, SharedSessionContractImplementor session) throws HibernateException; @@ -69,7 +69,7 @@ public interface QueryResultsCache { * * @throws HibernateException Indicates a problem delegating to the underlying cache. */ - List get( + List get( QueryKey key, String[] spaces, SharedSessionContractImplementor session) throws HibernateException; diff --git a/hibernate-core/src/main/java/org/hibernate/query/CommonQueryContract.java b/hibernate-core/src/main/java/org/hibernate/query/CommonQueryContract.java index cce9d62c0e..833c5e4d1f 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/CommonQueryContract.java +++ b/hibernate-core/src/main/java/org/hibernate/query/CommonQueryContract.java @@ -505,9 +505,9 @@ public interface CommonQueryContract { CommonQueryContract setProperties(Object bean); /** - * Bind the values of the given Map for each named parameters of the query, - * matching key names with parameter names and mapping value types to - * Hibernate types using heuristics. + * Bind the values of the given {@code Map} to named parameters of the query, + * matching key names with parameter names and mapping value types to Hibernate + * types using heuristics. * * @param bean a {@link Map} of names to arguments * diff --git a/hibernate-core/src/main/java/org/hibernate/query/MutationQuery.java b/hibernate-core/src/main/java/org/hibernate/query/MutationQuery.java index 7435aecf0e..e1b814893d 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/MutationQuery.java +++ b/hibernate-core/src/main/java/org/hibernate/query/MutationQuery.java @@ -32,7 +32,7 @@ public interface MutationQuery extends CommonQueryContract { * Execute an insert, update, or delete statement, and return the * number of affected entities. *

- * For use with instances of {@code Query} created using + * For use with instances of {@code MutationQuery} created using * {@link QueryProducer#createMutationQuery(String)}, * {@link QueryProducer#createNamedMutationQuery(String)}, * {@link QueryProducer#createNativeMutationQuery(String)}, @@ -166,7 +166,7 @@ public interface MutationQuery extends CommonQueryContract { MutationQuery setProperties(Object bean); @Override - MutationQuery setProperties(Map bean); + MutationQuery setProperties(@SuppressWarnings("rawtypes") Map bean); @Override MutationQuery setHibernateFlushMode(FlushMode flushMode); diff --git a/hibernate-core/src/main/java/org/hibernate/query/SelectionQuery.java b/hibernate-core/src/main/java/org/hibernate/query/SelectionQuery.java index 67e154bef2..c0de40965b 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/SelectionQuery.java +++ b/hibernate-core/src/main/java/org/hibernate/query/SelectionQuery.java @@ -452,5 +452,5 @@ public interface SelectionQuery extends CommonQueryContract { SelectionQuery setProperties(Object bean); @Override - SelectionQuery setProperties(Map bean); + SelectionQuery setProperties(@SuppressWarnings("rawtypes") Map bean); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/spi/DelegatingQueryOptions.java b/hibernate-core/src/main/java/org/hibernate/query/spi/DelegatingQueryOptions.java index 34bca433f3..4c1894193b 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/spi/DelegatingQueryOptions.java +++ b/hibernate-core/src/main/java/org/hibernate/query/spi/DelegatingQueryOptions.java @@ -49,12 +49,12 @@ public class DelegatingQueryOptions implements QueryOptions { } @Override - public TupleTransformer getTupleTransformer() { + public TupleTransformer getTupleTransformer() { return queryOptions.getTupleTransformer(); } @Override - public ResultListTransformer getResultListTransformer() { + public ResultListTransformer getResultListTransformer() { return queryOptions.getResultListTransformer(); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/spi/QueryOptions.java b/hibernate-core/src/main/java/org/hibernate/query/spi/QueryOptions.java index 3351d8b616..da41d08181 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/spi/QueryOptions.java +++ b/hibernate-core/src/main/java/org/hibernate/query/spi/QueryOptions.java @@ -54,13 +54,13 @@ public interface QueryOptions { * Transformer applied to the query to transform the structure of each "row" * in the results */ - TupleTransformer getTupleTransformer(); + TupleTransformer getTupleTransformer(); /** * Transformer applied to the query to transform the structure of the * overall results */ - ResultListTransformer getResultListTransformer(); + ResultListTransformer getResultListTransformer(); /** * Should results from the query be cached? @@ -167,13 +167,8 @@ public interface QueryOptions { */ default boolean hasLimit() { final Limit limit = getLimit(); - if ( limit != null ) { - if ( limit.getFirstRow() != null || limit.getMaxRows() != null ) { - return true; - } - } - - return false; + return limit != null + && (limit.getFirstRow() != null || limit.getMaxRows() != null); } /** diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/ConcreteSqmSelectQueryPlan.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/ConcreteSqmSelectQueryPlan.java index c8043714e3..6fd5406d11 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/ConcreteSqmSelectQueryPlan.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/ConcreteSqmSelectQueryPlan.java @@ -24,6 +24,7 @@ import org.hibernate.internal.EmptyScrollableResults; import org.hibernate.internal.util.collections.ArrayHelper; import org.hibernate.metamodel.mapping.MappingModelExpressable; import org.hibernate.query.IllegalQueryOperationException; +import org.hibernate.query.TupleTransformer; import org.hibernate.query.criteria.JpaSelection; import org.hibernate.query.spi.DomainQueryExecutionContext; import org.hibernate.query.spi.QueryEngine; @@ -252,9 +253,12 @@ public class ConcreteSqmSelectQueryPlan implements SelectQueryPlan { } } + + @SuppressWarnings("unchecked") + TupleTransformer tupleTransformer = (TupleTransformer) queryOptions.getTupleTransformer(); return new RowTransformerTupleTransformerAdapter( ArrayHelper.toStringArray( aliases ), - queryOptions.getTupleTransformer() + tupleTransformer ); } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/exec/internal/JdbcSelectExecutorStandardImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/exec/internal/JdbcSelectExecutorStandardImpl.java index 7d6535ce46..12d2e05caa 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/exec/internal/JdbcSelectExecutorStandardImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/exec/internal/JdbcSelectExecutorStandardImpl.java @@ -213,8 +213,8 @@ public class JdbcSelectExecutorStandardImpl implements JdbcSelectExecutor { final Integer timeout = queryOptions.getTimeout(); final FlushMode flushMode = queryOptions.getFlushMode(); final AppliedGraph appliedGraph = queryOptions.getAppliedGraph(); - final TupleTransformer tupleTransformer = queryOptions.getTupleTransformer(); - final ResultListTransformer resultListTransformer = queryOptions.getResultListTransformer(); + final TupleTransformer tupleTransformer = queryOptions.getTupleTransformer(); + final ResultListTransformer resultListTransformer = queryOptions.getResultListTransformer(); final Boolean resultCachingEnabled = queryOptions.isResultCachingEnabled(); final CacheRetrieveMode cacheRetrieveMode = queryOptions.getCacheRetrieveMode(); final CacheStoreMode cacheStoreMode = queryOptions.getCacheStoreMode(); @@ -251,12 +251,12 @@ public class JdbcSelectExecutorStandardImpl implements JdbcSelectExecutor { } @Override - public TupleTransformer getTupleTransformer() { + public TupleTransformer getTupleTransformer() { return tupleTransformer; } @Override - public ResultListTransformer getResultListTransformer() { + public ResultListTransformer getResultListTransformer() { return resultListTransformer; } @@ -346,7 +346,9 @@ public class JdbcSelectExecutorStandardImpl implements JdbcSelectExecutor { ); if ( rowTransformer == null ) { - final TupleTransformer tupleTransformer = executionContext.getQueryOptions().getTupleTransformer(); + @SuppressWarnings("unchecked") + final TupleTransformer tupleTransformer = (TupleTransformer) + executionContext.getQueryOptions().getTupleTransformer(); if ( tupleTransformer == null ) { rowTransformer = RowTransformerPassThruImpl.instance(); } @@ -449,12 +451,11 @@ public class JdbcSelectExecutorStandardImpl implements JdbcSelectExecutor { private int getResultSize(T result) { if ( result instanceof List ) { - return ( (List) result ).size(); + return ( (List) result ).size(); } return -1; } - @SuppressWarnings("unchecked") private JdbcValues resolveJdbcValuesSource( String queryIdentifier, JdbcSelect jdbcSelect, @@ -465,7 +466,7 @@ public class JdbcSelectExecutorStandardImpl implements JdbcSelectExecutor { final SessionFactoryImplementor factory = session.getFactory(); final boolean queryCacheEnabled = factory.getSessionFactoryOptions().isQueryCacheEnabled(); - final List cachedResults; + final List cachedResults; final CacheMode cacheMode = JdbcExecHelper.resolveCacheMode( executionContext ); final JdbcValuesMappingProducer mappingProducer = jdbcSelect.getJdbcValuesMappingProducer(); diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesCacheHit.java b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesCacheHit.java index b0b300fd20..fd6b1fb338 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesCacheHit.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesCacheHit.java @@ -40,11 +40,11 @@ public class JdbcValuesCacheHit extends AbstractJdbcValues { this.resolvedMapping = resolvedMapping; } - public JdbcValuesCacheHit(List cachedResults, JdbcValuesMapping resolvedMapping) { + public JdbcValuesCacheHit(List cachedResults, JdbcValuesMapping resolvedMapping) { this( extractData( cachedResults ), resolvedMapping ); } - private static Object[][] extractData(List cachedResults) { + private static Object[][] extractData(List cachedResults) { if ( CollectionHelper.isEmpty( cachedResults ) ) { return NO_DATA; }