diff --git a/hibernate-core/src/main/java/org/hibernate/SynchronizeableQuery.java b/hibernate-core/src/main/java/org/hibernate/SynchronizeableQuery.java index 8209770985..639600253a 100644 --- a/hibernate-core/src/main/java/org/hibernate/SynchronizeableQuery.java +++ b/hibernate-core/src/main/java/org/hibernate/SynchronizeableQuery.java @@ -46,8 +46,8 @@ public interface SynchronizeableQuery { */ default SynchronizeableQuery addSynchronizedQuerySpace(String... querySpaces) { if ( querySpaces != null ) { - for ( int i = 0; i < querySpaces.length; i++ ) { - addSynchronizedQuerySpace( querySpaces[i] ); + for (String querySpace : querySpaces) { + addSynchronizedQuerySpace(querySpace); } } return this; @@ -84,8 +84,8 @@ public interface SynchronizeableQuery { */ default SynchronizeableQuery addSynchronizedEntityName(String... entityNames) throws MappingException { if ( entityNames != null ) { - for ( int i = 0; i < entityNames.length; i++ ) { - addSynchronizedEntityName( entityNames[i] ); + for (String entityName : entityNames) { + addSynchronizedEntityName(entityName); } } return this; @@ -101,16 +101,15 @@ public interface SynchronizeableQuery { * * @throws MappingException Indicates the given class could not be resolved as an entity */ - @SuppressWarnings( "rawtypes" ) - SynchronizeableQuery addSynchronizedEntityClass(Class entityClass) throws MappingException; + SynchronizeableQuery addSynchronizedEntityClass(@SuppressWarnings("rawtypes") Class entityClass) throws MappingException; /** * Adds one-or-more entities (by class) whose tables should be added as synchronized spaces */ default SynchronizeableQuery addSynchronizedEntityClass(Class... entityClasses) throws MappingException { if ( entityClasses != null ) { - for ( int i = 0; i < entityClasses.length; i++ ) { - addSynchronizedEntityClass( entityClasses[i] ); + for (Class entityClass : entityClasses) { + addSynchronizedEntityClass(entityClass); } } return this; diff --git a/hibernate-core/src/main/java/org/hibernate/procedure/ProcedureCall.java b/hibernate-core/src/main/java/org/hibernate/procedure/ProcedureCall.java index 7bae2e78f2..1b9eb04faa 100644 --- a/hibernate-core/src/main/java/org/hibernate/procedure/ProcedureCall.java +++ b/hibernate-core/src/main/java/org/hibernate/procedure/ProcedureCall.java @@ -222,7 +222,7 @@ public interface ProcedureCall @Override ProcedureCall addSynchronizedEntityName(String entityName) throws MappingException; - @Override + @Override @SuppressWarnings("rawtypes") ProcedureCall addSynchronizedEntityClass(Class entityClass) throws MappingException; @Override diff --git a/hibernate-core/src/main/java/org/hibernate/procedure/internal/ProcedureCallImpl.java b/hibernate-core/src/main/java/org/hibernate/procedure/internal/ProcedureCallImpl.java index 049862d4d3..cc1864baaf 100644 --- a/hibernate-core/src/main/java/org/hibernate/procedure/internal/ProcedureCallImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/procedure/internal/ProcedureCallImpl.java @@ -744,7 +744,7 @@ public class ProcedureCallImpl } @Override - public ProcedureCallImplementor addSynchronizedEntityClass(Class entityClass) { + public ProcedureCallImplementor addSynchronizedEntityClass(@SuppressWarnings("rawtypes") Class entityClass) { addSynchronizedQuerySpaces( getSession().getFactory().getMetamodel().entityPersister( entityClass.getName() ) ); return this; } @@ -801,12 +801,12 @@ public class ProcedureCallImpl } @Override - protected void applyEntityGraphQueryHint(String hintName, RootGraphImplementor entityGraph) { + protected void applyEntityGraphQueryHint(String hintName, @SuppressWarnings("rawtypes") RootGraphImplementor entityGraph) { throw new IllegalStateException( "EntityGraph hints are not supported for ProcedureCall/StoredProcedureQuery" ); } @Override - public Query applyGraph(RootGraph graph, GraphSemantic semantic) { + public Query applyGraph(@SuppressWarnings("rawtypes") RootGraph graph, GraphSemantic semantic) { throw new IllegalStateException( "EntityGraph hints are not supported for ProcedureCall/StoredProcedureQuery" ); } @@ -819,8 +819,7 @@ public class ProcedureCallImpl @Override public boolean execute() { try { - final Output rtn = outputs().getCurrent(); - return ResultSetOutput.class.isInstance( rtn ); + return outputs().getCurrent() instanceof ResultSetOutput; } catch (NoMoreOutputsException e) { return false; @@ -887,7 +886,7 @@ public class ProcedureCallImpl @Override public boolean hasMoreResults() { - return outputs().goToNext() && ResultSetOutput.class.isInstance( outputs().getCurrent() ); + return outputs().goToNext() && outputs().getCurrent() instanceof ResultSetOutput; } @Override @@ -897,7 +896,7 @@ public class ProcedureCallImpl if ( rtn == null ) { return -1; } - else if ( UpdateCountOutput.class.isInstance( rtn ) ) { + else if ( rtn instanceof UpdateCountOutput ) { return ( (UpdateCountOutput) rtn ).getUpdateCount(); } else { @@ -923,7 +922,7 @@ public class ProcedureCallImpl } try { final Output rtn = outputs().getCurrent(); - if ( !ResultSetOutput.class.isInstance( rtn ) ) { + if ( !(rtn instanceof ResultSetOutput) ) { throw new IllegalStateException( "Current CallableStatement ou was not a ResultSet, but getResultList was called" ); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/NativeQuery.java b/hibernate-core/src/main/java/org/hibernate/query/NativeQuery.java index c88fe46b32..4ce1a7deac 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/NativeQuery.java +++ b/hibernate-core/src/main/java/org/hibernate/query/NativeQuery.java @@ -92,7 +92,7 @@ public interface NativeQuery extends Query, SynchronizeableQuery { * * @return {@code this}, for method chaining */ - NativeQuery addScalar(String columnAlias, BasicTypeReference type); + NativeQuery addScalar(String columnAlias, @SuppressWarnings("rawtypes") BasicTypeReference type); /** * Declare a scalar query result. @@ -106,7 +106,7 @@ public interface NativeQuery extends Query, SynchronizeableQuery { * * @return {@code this}, for method chaining */ - NativeQuery addScalar(String columnAlias, BasicDomainType type); + NativeQuery addScalar(String columnAlias, @SuppressWarnings("rawtypes") BasicDomainType type); /** * Declare a scalar query result using the specified result type. @@ -118,7 +118,7 @@ public interface NativeQuery extends Query, SynchronizeableQuery { * * @since 6.0 */ - NativeQuery addScalar(String columnAlias, Class javaType); + NativeQuery addScalar(String columnAlias, @SuppressWarnings("rawtypes") Class javaType); /** * Declare a scalar query result with an explicit conversion @@ -189,7 +189,7 @@ public interface NativeQuery extends Query, SynchronizeableQuery { * * @since 6.0 */ - NativeQuery addAttributeResult(String columnAlias, Class entityJavaType, String attributePath); + NativeQuery addAttributeResult(String columnAlias, @SuppressWarnings("rawtypes") Class entityJavaType, String attributePath); /** * Defines a result based on a specified attribute. Differs from adding a scalar in that @@ -213,7 +213,7 @@ public interface NativeQuery extends Query, SynchronizeableQuery { * * @since 6.0 */ - NativeQuery addAttributeResult(String columnAlias, SingularAttribute attribute); + NativeQuery addAttributeResult(String columnAlias, @SuppressWarnings("rawtypes") SingularAttribute attribute); /** * Add a new root return mapping, returning a {@link RootReturn} to allow @@ -238,7 +238,7 @@ public interface NativeQuery extends Query, SynchronizeableQuery { * * @since 3.6 */ - RootReturn addRoot(String tableAlias, Class entityType); + RootReturn addRoot(String tableAlias, @SuppressWarnings("rawtypes") Class entityType); /** * Declare a "root" entity, without specifying an alias. The expectation here is that the table alias is the @@ -281,7 +281,7 @@ public interface NativeQuery extends Query, SynchronizeableQuery { * * @return {@code this}, for method chaining */ - NativeQuery addEntity(Class entityType); + NativeQuery addEntity(@SuppressWarnings("rawtypes") Class entityType); /** * Declare a "root" entity. @@ -291,7 +291,7 @@ public interface NativeQuery extends Query, SynchronizeableQuery { * * @return {@code this}, for method chaining */ - NativeQuery addEntity(String tableAlias, Class entityType); + NativeQuery addEntity(String tableAlias, @SuppressWarnings("rawtypes") Class entityType); /** * Declare a "root" entity, specifying a lock mode. @@ -302,7 +302,7 @@ public interface NativeQuery extends Query, SynchronizeableQuery { * * @return {@code this}, for method chaining */ - NativeQuery addEntity(String tableAlias, Class entityClass, LockMode lockMode); + NativeQuery addEntity(String tableAlias, @SuppressWarnings("rawtypes") Class entityClass, LockMode lockMode); /** * Declare a join fetch result. @@ -507,7 +507,7 @@ public interface NativeQuery extends Query, SynchronizeableQuery { NativeQuery addSynchronizedEntityName(String entityName) throws MappingException; @Override - NativeQuery addSynchronizedEntityClass(Class entityClass) throws MappingException; + NativeQuery addSynchronizedEntityClass(@SuppressWarnings("rawtypes") Class entityClass) throws MappingException; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -567,7 +567,7 @@ public interface NativeQuery extends Query, SynchronizeableQuery { @Override NativeQuery setResultListTransformer(ResultListTransformer transformer); - @Override + @Override @SuppressWarnings("deprecation") NativeQuery setResultTransformer(ResultTransformer transformer); @@ -664,7 +664,7 @@ public interface NativeQuery extends Query, SynchronizeableQuery {

NativeQuery setParameterList(QueryParameter

parameter, Collection

values); @Override - NativeQuery setParameterList(String name, Collection values); + NativeQuery setParameterList(String name, @SuppressWarnings("rawtypes") Collection values); // @Override // default NativeQuery setParameterList(String name, Collection values, Type type) { @@ -678,7 +678,7 @@ public interface NativeQuery extends Query, SynchronizeableQuery { // NativeQuery setParameterList(String name, Object[] values, Type type); @Override - NativeQuery setParameterList(String name, Object[] values, AllowableParameterType type); + NativeQuery setParameterList(String name, Object[] values, @SuppressWarnings("rawtypes") AllowableParameterType type); @Override NativeQuery setParameterList(String name, Object[] values); @@ -702,7 +702,7 @@ public interface NativeQuery extends Query, SynchronizeableQuery {

NativeQuery setParameter(QueryParameter

parameter, P val, BasicTypeReference

type); @Override - NativeQuery setParameterList(int position, Collection values); + NativeQuery setParameterList(int position, @SuppressWarnings("rawtypes") Collection values); @Override

NativeQuery setParameterList(String name, Collection values, Class

type); @@ -720,7 +720,7 @@ public interface NativeQuery extends Query, SynchronizeableQuery { // NativeQuery setParameterList(int position, Object[] values, Type type); @Override - NativeQuery setParameterList(int position, Object[] values, AllowableParameterType type); + NativeQuery setParameterList(int position, Object[] values, @SuppressWarnings("rawtypes") AllowableParameterType type); @Override NativeQuery setParameterList(int position, Object[] values); @@ -729,5 +729,5 @@ public interface NativeQuery extends Query, SynchronizeableQuery { NativeQuery setProperties(Object bean); @Override - NativeQuery setProperties(Map bean); + NativeQuery setProperties(@SuppressWarnings("rawtypes") Map bean); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/Query.java b/hibernate-core/src/main/java/org/hibernate/query/Query.java index 6a1077bb4f..2a107f73a3 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/Query.java +++ b/hibernate-core/src/main/java/org/hibernate/query/Query.java @@ -77,7 +77,7 @@ public interface Query extends TypedQuery, CommonQueryContract { * * @return this - for method chaining */ - Query applyGraph(RootGraph graph, GraphSemantic semantic); + Query applyGraph(@SuppressWarnings("rawtypes") RootGraph graph, GraphSemantic semantic); /** * Apply the given graph using {@linkplain GraphSemantic#FETCH fetch semantics} @@ -85,7 +85,7 @@ public interface Query extends TypedQuery, CommonQueryContract { * @apiNote This method calls {@link #applyGraph(RootGraph, GraphSemantic)} using * {@link GraphSemantic#FETCH} as the semantic */ - default Query applyFetchGraph(RootGraph graph) { + default Query applyFetchGraph(@SuppressWarnings("rawtypes") RootGraph graph) { return applyGraph( graph, GraphSemantic.FETCH ); } @@ -96,7 +96,7 @@ public interface Query extends TypedQuery, CommonQueryContract { * {@link GraphSemantic#LOAD} as the semantic */ @SuppressWarnings("UnusedDeclaration") - default Query applyLoadGraph(RootGraph graph) { + default Query applyLoadGraph(@SuppressWarnings("rawtypes") RootGraph graph) { return applyGraph( graph, GraphSemantic.LOAD ); } @@ -541,7 +541,7 @@ public interface Query extends TypedQuery, CommonQueryContract { * * @return {@code this}, for method chaining */ - Query setParameterList(String name, Collection values); + Query setParameterList(String name, @SuppressWarnings("rawtypes") Collection values); /** * Bind multiple values to a positional query parameter. The Hibernate type of the parameter is @@ -554,7 +554,7 @@ public interface Query extends TypedQuery, CommonQueryContract { * * @return {@code this}, for method chaining */ - Query setParameterList(int position, Collection values); + Query setParameterList(int position, @SuppressWarnings("rawtypes") Collection values); /** * Bind multiple values to a named query parameter. The Hibernate type of the parameter is @@ -650,7 +650,7 @@ public interface Query extends TypedQuery, CommonQueryContract { * * @return {@code this}, for method chaining */ - Query setParameterList(String name, Object[] values, AllowableParameterType type); + Query setParameterList(String name, Object[] values, @SuppressWarnings("rawtypes") AllowableParameterType type); /** * Bind multiple values to a named query parameter. This is useful for binding @@ -662,7 +662,7 @@ public interface Query extends TypedQuery, CommonQueryContract { * * @return {@code this}, for method chaining */ - Query setParameterList(int position, Object[] values, AllowableParameterType type); + Query setParameterList(int position, Object[] values, @SuppressWarnings("rawtypes") AllowableParameterType type); /** * Bind multiple values to a named query parameter. The Hibernate type of the parameter is @@ -710,7 +710,7 @@ public interface Query extends TypedQuery, CommonQueryContract { * * @return {@code this}, for method chaining */ - Query setProperties(Map bean); + Query setProperties(@SuppressWarnings("rawtypes") Map bean); /** * @deprecated (since 5.2) Use {@link #setTupleTransformer} or {@link #setResultListTransformer} diff --git a/hibernate-core/src/main/java/org/hibernate/query/TupleTransformer.java b/hibernate-core/src/main/java/org/hibernate/query/TupleTransformer.java index a907860378..82182ad727 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/TupleTransformer.java +++ b/hibernate-core/src/main/java/org/hibernate/query/TupleTransformer.java @@ -11,16 +11,10 @@ import org.hibernate.sql.results.internal.RowTransformerTupleTransformerAdapter; /** * User hook for applying transformations of the query result tuples (the result "row"). * - * Ultimately, gets wrapped in a - * {@link RowTransformerTupleTransformerAdapter} + * Ultimately, gets wrapped in a {@link RowTransformerTupleTransformerAdapter} * to adapt the TupleTransformer to the {@link org.hibernate.sql.results.spi.RowTransformer} * contract, which is the thing actually used to process the results internally. * - * Note that {@link JpaTupleTransformer} is a special sub-type applications may use - * to transform the row into a JPA {@link jakarta.persistence.Tuple}. JpaTupleTransformer is - * deprecated as it is much more appropriate (and simpler) to simply specify the Query - * return type as Tuple - * * @see org.hibernate.transform.ResultTransformer * @see org.hibernate.sql.results.spi.RowTransformer * diff --git a/hibernate-core/src/main/java/org/hibernate/query/spi/AbstractQuery.java b/hibernate-core/src/main/java/org/hibernate/query/spi/AbstractQuery.java index 4cc09b7fc0..31cda2d62e 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/spi/AbstractQuery.java +++ b/hibernate-core/src/main/java/org/hibernate/query/spi/AbstractQuery.java @@ -383,6 +383,7 @@ public abstract class AbstractQuery implements QueryImplementor { return hints; } + @SuppressWarnings("deprecation") protected void collectHints(Map hints) { if ( getQueryOptions().getTimeout() != null ) { hints.put( HINT_TIMEOUT, getQueryOptions().getTimeout() ); @@ -445,7 +446,7 @@ public abstract class AbstractQuery implements QueryImplementor { } } - @Override + @Override @SuppressWarnings("deprecation") public QueryImplementor setHint(String hintName, Object value) { getSession().checkOpen( true ); @@ -532,7 +533,6 @@ public abstract class AbstractQuery implements QueryImplementor { DEPRECATION_LOGGER.deprecatedSetting( HINT_FETCHGRAPH, JAKARTA_HINT_FETCH_GRAPH ); } else { - assert HINT_LOADGRAPH.equals( hintName ); DEPRECATION_LOGGER.deprecatedSetting( HINT_FETCHGRAPH, JAKARTA_HINT_FETCH_GRAPH ); } @@ -712,8 +712,9 @@ public abstract class AbstractQuery implements QueryImplementor { return true; } - @SuppressWarnings( "UnusedReturnValue" ) + @SuppressWarnings({"UnusedReturnValue", "deprecation"}) protected boolean applyHibernateLockModeHint(LockMode lockMode) { + //TODO: this method is a noop. Delete it? final LockOptions lockOptions; if ( lockMode == LockMode.NONE ) { lockOptions = NONE; @@ -982,6 +983,7 @@ public abstract class AbstractQuery implements QueryImplementor { locateBinding( parameter ).setBindValue( null, type ); } else if ( value instanceof Collection ) { + //TODO: this looks wrong to me: how can value be both a P and a (Collection

)? locateBinding( parameter ).setBindValues( (Collection

) value ); } else { @@ -1116,13 +1118,13 @@ public abstract class AbstractQuery implements QueryImplementor { } @Override - public QueryImplementor setParameterList(String name, Collection values) { + public QueryImplementor setParameterList(String name, @SuppressWarnings("rawtypes") Collection values) { locateBinding( name ).setBindValues( values ); return this; } @Override - public QueryImplementor setParameterList(int position, Collection values) { + public QueryImplementor setParameterList(int position, @SuppressWarnings("rawtypes") Collection values) { locateBinding( position ).setBindValues( values ); return this; } @@ -1151,15 +1153,15 @@ public abstract class AbstractQuery implements QueryImplementor { return this; } - @Override - public QueryImplementor setParameterList(String name, Object[] values, AllowableParameterType type) { - locateBinding( name ).setBindValues( Arrays.asList( values ), (AllowableParameterType) type ); + @Override @SuppressWarnings({"rawtypes", "unchecked"}) + public QueryImplementor setParameterList(String name, Object[] values, AllowableParameterType type) { + locateBinding( name ).setBindValues( Arrays.asList( values ), type ); return this; } - @Override - public QueryImplementor setParameterList(int position, Object[] values, AllowableParameterType type) { - locateBinding( position ).setBindValues( Arrays.asList( values ), (AllowableParameterType) type ); + @Override @SuppressWarnings({"rawtypes", "unchecked"}) + public QueryImplementor setParameterList(int position, Object[] values, AllowableParameterType type) { + locateBinding( position ).setBindValues( Arrays.asList( values ), type ); return this; } @@ -1288,7 +1290,7 @@ public abstract class AbstractQuery implements QueryImplementor { return (T) binding.getBindValues(); } else { - return (T) binding.getBindValue(); + return binding.getBindValue(); } } @@ -1303,7 +1305,7 @@ public abstract class AbstractQuery implements QueryImplementor { final QueryParameterBinding binding = getQueryParameterBindings().getBinding( parameter ); if ( binding == null || !binding.isBound() ) { - throw new IllegalStateException( "Parameter value not yet bound : " + parameter.toString() ); + throw new IllegalStateException( "Parameter value not yet bound : " + parameter ); } if ( binding.isMultiValued() ) { @@ -1342,10 +1344,10 @@ public abstract class AbstractQuery implements QueryImplementor { private FlushMode sessionFlushMode; private CacheMode sessionCacheMode; - protected void beforeQuery(boolean requiresTxn) { + protected void beforeQuery() { getQueryParameterBindings().validate(); - getSession().prepareForQueryExecution( requiresTxn ); + getSession().prepareForQueryExecution(false); prepareForExecution(); @@ -1412,7 +1414,7 @@ public abstract class AbstractQuery implements QueryImplementor { } @Override - public QueryImplementor setProperties(Map map) { + public QueryImplementor setProperties(@SuppressWarnings("rawtypes") Map map) { for ( String paramName : getParameterMetadata().getNamedParameterNames() ) { final Object object = map.get( paramName ); if ( object == null ) { @@ -1421,15 +1423,14 @@ public abstract class AbstractQuery implements QueryImplementor { } } else { - Class retType = object.getClass(); - if ( Collection.class.isAssignableFrom( retType ) ) { - setParameterList( paramName, (Collection) object ); + if ( object instanceof Collection ) { + setParameterList( paramName, (Collection) object ); } - else if ( retType.isArray() ) { + else if ( object instanceof Object[] ) { setParameterList( paramName, (Object[]) object ); } else { - setParameter( paramName, object, determineType( paramName, retType ) ); + setParameter( paramName, object, determineType( paramName, object.getClass() ) ); } } } @@ -1454,7 +1455,7 @@ public abstract class AbstractQuery implements QueryImplementor { @Override public List list() { - beforeQuery( false ); + beforeQuery(); boolean success = false; try { final List result = doList(); @@ -1536,7 +1537,7 @@ public abstract class AbstractQuery implements QueryImplementor { @Override public int executeUpdate() throws HibernateException { getSession().checkTransactionNeededForUpdateOperation( "Executing an update/delete query" ); - beforeQuery( false ); + beforeQuery(); boolean success = false; try { final int result = doExecuteUpdate(); diff --git a/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeQueryImpl.java b/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeQueryImpl.java index fdbdb80a98..d843ff2107 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeQueryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeQueryImpl.java @@ -46,7 +46,6 @@ import org.hibernate.jpa.internal.util.LockModeTypeHelper; import org.hibernate.jpa.spi.NativeQueryTupleTransformer; import org.hibernate.metamodel.model.domain.AllowableParameterType; import org.hibernate.metamodel.model.domain.BasicDomainType; -import org.hibernate.query.Limit; import org.hibernate.query.NativeQuery; import org.hibernate.query.ParameterMetadata; import org.hibernate.query.Query; @@ -127,7 +126,6 @@ public class NativeQueryImpl private Callback callback; private Object collectionKey; - private NativeQueryInterpreter nativeQueryInterpreter; /** * Constructs a NativeQueryImpl given a sql query defined in the mappings. @@ -366,7 +364,7 @@ public class NativeQueryImpl .getService( NativeQueryInterpreter.class ) .recognizeParameters( sqlString, parameterRecognizer ); - return new ParameterInterpretationImpl( sqlString, parameterRecognizer ); + return new ParameterInterpretationImpl( parameterRecognizer ); } ); } @@ -503,12 +501,12 @@ public class NativeQueryImpl } @Override - public Query applyGraph(RootGraph graph, GraphSemantic semantic) { + public Query applyGraph(@SuppressWarnings("rawtypes") RootGraph graph, GraphSemantic semantic) { throw new HibernateException( "A native SQL query cannot use EntityGraphs" ); } @Override - public NativeQueryImplementor setTupleTransformer(TupleTransformer transformer) { + public NativeQueryImplementor setTupleTransformer(@SuppressWarnings("rawtypes") TupleTransformer transformer) { return (NativeQueryImplementor) super.setTupleTransformer( transformer ); } @@ -565,9 +563,7 @@ public class NativeQueryImpl } if ( effectiveFlushMode == FlushMode.AUTO ) { - if ( getSession().getFactory().getSessionFactoryOptions().isJpaBootstrap() ) { - return true; - } + return getSession().getFactory().getSessionFactoryOptions().isJpaBootstrap(); } } @@ -594,7 +590,7 @@ public class NativeQueryImpl private NativeSelectQueryPlan createQueryPlan(ResultSetMapping resultSetMapping) { final String sqlString = expandParameterLists(); - final NativeSelectQueryDefinition queryDefinition = new NativeSelectQueryDefinition() { + final NativeSelectQueryDefinition queryDefinition = new NativeSelectQueryDefinition<>() { @Override public String getSqlString() { return sqlString; @@ -788,10 +784,6 @@ public class NativeQueryImpl return !query.parameterBindings.hasAnyMultiValuedBindings(); } - private static boolean hasLimit(Limit limit) { - return limit.getFirstRow() != null || limit.getMaxRows() != null; - } - @Override public ScrollableResultsImplementor scroll(ScrollMode scrollMode) { return resolveSelectQueryPlan().performScroll( scrollMode, this ); @@ -834,7 +826,7 @@ public class NativeQueryImpl } @Override - public NativeQueryImplementor setCollectionKey(Object key) { + public NativeQueryImplementor setCollectionKey(Object key) { this.collectionKey = key; return this; } @@ -850,7 +842,7 @@ public class NativeQueryImpl } @Override - public NativeQuery addScalar(String columnAlias, BasicTypeReference type) { + public NativeQuery addScalar(String columnAlias, @SuppressWarnings("rawtypes") BasicTypeReference type) { return registerBuilder( Builders.scalar( columnAlias, @@ -860,12 +852,12 @@ public class NativeQueryImpl } @Override - public NativeQueryImplementor addScalar(String columnAlias, BasicDomainType type) { + public NativeQueryImplementor addScalar(String columnAlias, @SuppressWarnings("rawtypes") BasicDomainType type) { return registerBuilder( Builders.scalar( columnAlias, (BasicType) type ) ); } @Override - public NativeQueryImplementor addScalar(String columnAlias, Class javaType) { + public NativeQueryImplementor addScalar(String columnAlias, @SuppressWarnings("rawtypes") Class javaType) { return registerBuilder( Builders.scalar( columnAlias, javaType, getSessionFactory() ) ); } @@ -916,7 +908,7 @@ public class NativeQueryImpl @Override public NativeQueryImplementor addAttributeResult( String columnAlias, - Class entityJavaType, + @SuppressWarnings("rawtypes") Class entityJavaType, String attributePath) { return addAttributeResult( columnAlias, entityJavaType.getName(), attributePath ); } @@ -933,7 +925,7 @@ public class NativeQueryImpl @Override public NativeQueryImplementor addAttributeResult( String columnAlias, - SingularAttribute attribute) { + @SuppressWarnings("rawtypes") SingularAttribute attribute) { registerBuilder( Builders.attributeResult( columnAlias, attribute ) ); return this; } @@ -950,7 +942,7 @@ public class NativeQueryImpl } @Override - public DynamicResultBuilderEntityStandard addRoot(String tableAlias, Class entityType) { + public DynamicResultBuilderEntityStandard addRoot(String tableAlias, @SuppressWarnings("rawtypes") Class entityType) { return addRoot( tableAlias, entityType.getName() ); } @@ -972,17 +964,17 @@ public class NativeQueryImpl } @Override - public NativeQueryImplementor addEntity(Class entityType) { + public NativeQueryImplementor addEntity(@SuppressWarnings("rawtypes") Class entityType) { return addEntity( entityType.getName() ); } @Override - public NativeQueryImplementor addEntity(String tableAlias, Class entityClass) { + public NativeQueryImplementor addEntity(String tableAlias, @SuppressWarnings("rawtypes") Class entityClass) { return addEntity( tableAlias, entityClass.getName() ); } @Override - public NativeQueryImplementor addEntity(String tableAlias, Class entityClass, LockMode lockMode) { + public NativeQueryImplementor addEntity(String tableAlias, @SuppressWarnings("rawtypes") Class entityClass, LockMode lockMode) { return addEntity( tableAlias, entityClass.getName(), lockMode ); } @@ -1057,7 +1049,7 @@ public class NativeQueryImpl } @Override - public NativeQueryImplementor addSynchronizedEntityClass(Class entityClass) throws MappingException { + public NativeQueryImplementor addSynchronizedEntityClass(@SuppressWarnings("rawtypes") Class entityClass) throws MappingException { addQuerySpaces( getSession().getFactory().getMetamodel().entityPersister( entityClass.getName() ).getQuerySpaces() ); return this; } @@ -1161,18 +1153,16 @@ public class NativeQueryImpl addSynchronizedQuerySpace( (String) value ); } else if ( value instanceof String[] ) { - final String[] strings = (String[]) value; - for ( int i = 0; i < strings.length; i++ ) { - addSynchronizedQuerySpace( strings[i] ); + for (String string : (String[]) value) { + addSynchronizedQuerySpace(string); } } else if ( value instanceof Class ) { addSynchronizedEntityClass( (Class) value ); } else if ( value instanceof Class[] ) { - final Class[] classes = (Class[]) value; - for ( int i = 0; i < classes.length; i++ ) { - addSynchronizedEntityClass( classes[i] ); + for (Class aClass : (Class[]) value) { + addSynchronizedEntityClass(aClass); } } else if ( value instanceof List ) { @@ -1200,7 +1190,7 @@ public class NativeQueryImpl else if ( value instanceof LockModeType ) { applyLockModeTypeHint( (LockModeType) value ); } - else if ( String.class.isInstance( value ) ) { + else if ( value instanceof String ) { applyHibernateLockModeHint( LockModeTypeHelper.interpretLockMode( value ) ); } else { @@ -1315,19 +1305,25 @@ public class NativeQueryImpl } @Override - public

NativeQueryImplementor setParameterList(int position, Collection values, AllowableParameterType

type) { + public

NativeQueryImplementor setParameterList( + int position, Collection values, + AllowableParameterType

type) { super.setParameterList( position, values, type ); return this; } @Override - public NativeQueryImplementor setParameterList(String name, Object[] values, AllowableParameterType type) { + public NativeQueryImplementor setParameterList( + String name, Object[] values, + @SuppressWarnings("rawtypes") AllowableParameterType type) { super.setParameterList( name, values, type ); return this; } @Override - public NativeQueryImplementor setParameterList(int position, Object[] values, AllowableParameterType type) { + public NativeQueryImplementor setParameterList( + int position, Object[] values, + @SuppressWarnings("rawtypes") AllowableParameterType type) { super.setParameterList( position, values, type ); return this; } @@ -1392,7 +1388,7 @@ public class NativeQueryImpl } @Override - public NativeQueryImplementor setParameterList(String name, Collection values) { + public NativeQueryImplementor setParameterList(String name, @SuppressWarnings("rawtypes") Collection values) { super.setParameterList( name, values ); return this; } @@ -1451,14 +1447,14 @@ public class NativeQueryImpl return this; } - @Override + @Override @SuppressWarnings("deprecation") public NativeQueryImplementor setResultTransformer(ResultTransformer transformer) { super.setResultTransformer( transformer ); return this; } @Override - public NativeQueryImplementor setProperties(Map map) { + public NativeQueryImplementor setProperties(@SuppressWarnings("rawtypes") Map map) { super.setProperties( map ); return this; } @@ -1518,7 +1514,7 @@ public class NativeQueryImpl } @Override - public NativeQueryImplementor setParameterList(int position, Collection values) { + public NativeQueryImplementor setParameterList(int position, @SuppressWarnings("rawtypes") Collection values) { super.setParameterList( position, values ); return this; } @@ -1552,7 +1548,7 @@ public class NativeQueryImpl } @Override - protected void applyEntityGraphQueryHint(String hintName, RootGraphImplementor entityGraph) { + protected void applyEntityGraphQueryHint(String hintName, @SuppressWarnings("rawtypes") RootGraphImplementor entityGraph) { throw new HibernateException( "A native SQL query cannot use EntityGraphs" ); } @@ -1562,7 +1558,7 @@ public class NativeQueryImpl private final Map> positionalParameters; private final Map> namedParameters; - public ParameterInterpretationImpl(String sqlString, ParameterRecognizerImpl parameterRecognizer) { + public ParameterInterpretationImpl(ParameterRecognizerImpl parameterRecognizer) { this.sqlString = parameterRecognizer.getAdjustedSqlString(); this.parameterList = parameterRecognizer.getParameterList(); this.positionalParameters = parameterRecognizer.getPositionalQueryParameters(); diff --git a/hibernate-core/src/main/java/org/hibernate/query/sql/spi/NativeQueryImplementor.java b/hibernate-core/src/main/java/org/hibernate/query/sql/spi/NativeQueryImplementor.java index d2d2fcd7a8..271aab0f26 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sql/spi/NativeQueryImplementor.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sql/spi/NativeQueryImplementor.java @@ -43,7 +43,9 @@ import org.hibernate.type.BasicTypeReference; */ @Incubating public interface NativeQueryImplementor extends QueryImplementor, NativeQuery, NameableQuery { - NativeQueryImplementor setCollectionKey(Object key); + + //TODO: this method is no longer used. Can it be deleted? + NativeQueryImplementor setCollectionKey(Object key); @Override default LockOptions getLockOptions() { @@ -66,10 +68,10 @@ public interface NativeQueryImplementor extends QueryImplementor, NativeQu NativeQueryImplementor addScalar(String columnAlias); @Override - NativeQueryImplementor addScalar(String columnAlias, BasicDomainType type); + NativeQueryImplementor addScalar(String columnAlias, @SuppressWarnings("rawtypes") BasicDomainType type); @Override - NativeQueryImplementor addScalar(String columnAlias, Class javaType); + NativeQueryImplementor addScalar(String columnAlias, @SuppressWarnings("rawtypes") Class javaType); @Override NativeQueryImplementor addScalar(String columnAlias, Class relationalJavaType, AttributeConverter converter); @@ -88,13 +90,13 @@ public interface NativeQueryImplementor extends QueryImplementor, NativeQu Class> converter); @Override - NativeQueryImplementor addAttributeResult(String columnAlias, Class entityJavaType, String attributePath); + NativeQueryImplementor addAttributeResult(String columnAlias, @SuppressWarnings("rawtypes") Class entityJavaType, String attributePath); @Override NativeQueryImplementor addAttributeResult(String columnAlias, String entityName, String attributePath); @Override - NativeQueryImplementor addAttributeResult(String columnAlias, SingularAttribute attribute); + NativeQueryImplementor addAttributeResult(String columnAlias, @SuppressWarnings("rawtypes") SingularAttribute attribute); @Override DynamicResultBuilderEntityStandard addRoot(String tableAlias, String entityName); @@ -109,13 +111,13 @@ public interface NativeQueryImplementor extends QueryImplementor, NativeQu NativeQueryImplementor addEntity(String tableAlias, String entityName, LockMode lockMode); @Override - NativeQueryImplementor addEntity(Class entityType); + NativeQueryImplementor addEntity(@SuppressWarnings("rawtypes") Class entityType); @Override - NativeQueryImplementor addEntity(String tableAlias, Class entityType); + NativeQueryImplementor addEntity(String tableAlias, @SuppressWarnings("rawtypes") Class entityType); @Override - NativeQueryImplementor addEntity(String tableAlias, Class entityClass, LockMode lockMode); + NativeQueryImplementor addEntity(String tableAlias, @SuppressWarnings("rawtypes") Class entityClass, LockMode lockMode); @Override NativeQueryImplementor addJoin(String tableAlias, String path); @@ -136,7 +138,7 @@ public interface NativeQueryImplementor extends QueryImplementor, NativeQu NativeQueryImplementor addSynchronizedEntityName(String entityName) throws MappingException; @Override - NativeQueryImplementor addSynchronizedEntityClass(Class entityClass) throws MappingException; + NativeQueryImplementor addSynchronizedEntityClass(@SuppressWarnings("rawtypes") Class entityClass) throws MappingException; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -253,7 +255,7 @@ public interface NativeQueryImplementor extends QueryImplementor, NativeQu Collection

values); @Override - NativeQueryImplementor setParameterList(String name, Collection values); + NativeQueryImplementor setParameterList(String name, @SuppressWarnings("rawtypes") Collection values); // @Override // default NativeQueryImplementor setParameterList(String name, Collection values, Type type) { @@ -269,7 +271,7 @@ public interface NativeQueryImplementor extends QueryImplementor, NativeQu // } @Override - NativeQueryImplementor setParameterList(String name, Object[] values, AllowableParameterType type); + NativeQueryImplementor setParameterList(String name, Object[] values, @SuppressWarnings("rawtypes") AllowableParameterType type); @Override NativeQueryImplementor setParameterList(String name, Object[] values); @@ -278,7 +280,7 @@ public interface NativeQueryImplementor extends QueryImplementor, NativeQu NativeQueryImplementor setProperties(Object bean); @Override - NativeQueryImplementor setProperties(Map bean); + NativeQueryImplementor setProperties(@SuppressWarnings("rawtypes") Map bean); @Override NativeQueryImplementor setParameter( @@ -314,7 +316,7 @@ public interface NativeQueryImplementor extends QueryImplementor, NativeQu NativeQueryImplementor setParameter(String name, Instant value, TemporalType temporalType); @Override - NativeQueryImplementor setTupleTransformer(TupleTransformer transformer); + NativeQueryImplementor setTupleTransformer(@SuppressWarnings("rawtypes") TupleTransformer transformer); @Override NativeQueryImplementor setResultListTransformer(ResultListTransformer transformer); @@ -353,7 +355,7 @@ public interface NativeQueryImplementor extends QueryImplementor, NativeQu NativeQueryImplementor setParameter(Parameter param, OffsetDateTime value, TemporalType temporalType); @Override - NativeQueryImplementor setParameterList(int position, Collection values); + NativeQueryImplementor setParameterList(int position, @SuppressWarnings("rawtypes") Collection values); @Override

NativeQueryImplementor setParameterList(String name, Collection values, Class

type); @@ -371,7 +373,7 @@ public interface NativeQueryImplementor extends QueryImplementor, NativeQu // NativeQueryImplementor setParameterList(int position, Object[] values, Type type); @Override - NativeQueryImplementor setParameterList(int position, Object[] values, AllowableParameterType type); + NativeQueryImplementor setParameterList(int position, Object[] values, @SuppressWarnings("rawtypes") AllowableParameterType type); @Override NativeQueryImplementor setParameterList(int position, Object[] values); diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/QuerySqmImpl.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/QuerySqmImpl.java index c7078df5ab..58b12af3c1 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/QuerySqmImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/QuerySqmImpl.java @@ -541,13 +541,13 @@ public class QuerySqmImpl } @Override - public HqlQueryImplementor applyGraph(RootGraph graph, GraphSemantic semantic) { + public HqlQueryImplementor applyGraph(@SuppressWarnings("rawtypes") RootGraph graph, GraphSemantic semantic) { queryOptions.applyGraph( (RootGraphImplementor) graph, semantic ); return this; } @Override - protected void applyEntityGraphQueryHint(String hintName, RootGraphImplementor entityGraph) { + protected void applyEntityGraphQueryHint(String hintName, @SuppressWarnings("rawtypes") RootGraphImplementor entityGraph) { final GraphSemantic graphSemantic = GraphSemantic.fromJpaHintName( hintName ); applyGraph( entityGraph, graphSemantic );