From 8a2c000b78622953a9ccfd3b38d56e9049a2cfc6 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Sat, 22 Jan 2022 11:59:06 +0100 Subject: [PATCH] fix some generics warnings --- .../engine/spi/SessionDelegatorBaseImpl.java | 18 +++++++------ .../AbstractSharedSessionContract.java | 26 ++++++++++--------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionDelegatorBaseImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionDelegatorBaseImpl.java index adc4f8c69b..f1fdd141b1 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionDelegatorBaseImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionDelegatorBaseImpl.java @@ -450,12 +450,12 @@ public class SessionDelegatorBaseImpl implements SessionImplementor { } @Override - public MutationQuery createMutationQuery(CriteriaUpdate updateQuery) { + public MutationQuery createMutationQuery(@SuppressWarnings("rawtypes") CriteriaUpdate updateQuery) { return delegate().createMutationQuery( updateQuery ); } @Override - public MutationQuery createMutationQuery(CriteriaDelete deleteQuery) { + public MutationQuery createMutationQuery(@SuppressWarnings("rawtypes") CriteriaDelete deleteQuery) { return delegate().createMutationQuery( deleteQuery ); } @@ -464,12 +464,12 @@ public class SessionDelegatorBaseImpl implements SessionImplementor { return queryDelegate().createQuery( criteriaQuery ); } - @Override + @Override @SuppressWarnings("rawtypes") public QueryImplementor createQuery(CriteriaUpdate updateQuery) { return queryDelegate().createQuery( updateQuery ); } - @Override + @Override @SuppressWarnings("rawtypes") public QueryImplementor createQuery(CriteriaDelete deleteQuery) { return queryDelegate().createQuery( deleteQuery ); } @@ -520,12 +520,14 @@ public class SessionDelegatorBaseImpl implements SessionImplementor { } @Override @SuppressWarnings({"rawtypes", "unchecked"}) + //note: we're doing something a bit funny here to work around + // the clashing signatures declared by the supertypes public NativeQueryImplementor createNativeQuery(String sqlString, Class resultClass) { return queryDelegate().createNativeQuery( sqlString, resultClass ); } - @Override @SuppressWarnings({"rawtypes", "unchecked"}) - public NativeQueryImplementor createNativeQuery(String sqlString, Class resultClass, String tableAlias) { + @Override + public NativeQueryImplementor createNativeQuery(String sqlString, Class resultClass, String tableAlias) { return queryDelegate().createNativeQuery( sqlString, resultClass, tableAlias ); } @@ -534,8 +536,8 @@ public class SessionDelegatorBaseImpl implements SessionImplementor { return queryDelegate().createNativeQuery( sqlString, resultSetMappingName ); } - @Override @SuppressWarnings({"rawtypes", "unchecked"}) - public NativeQueryImplementor createNativeQuery(String sqlString, String resultSetMappingName, Class resultClass) { + @Override + public NativeQueryImplementor createNativeQuery(String sqlString, String resultSetMappingName, Class resultClass) { return queryDelegate().createNativeQuery( sqlString, resultSetMappingName, resultClass ); } diff --git a/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java b/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java index ccd0dfca75..3bfec239e4 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java @@ -792,9 +792,10 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont return query; } - @Override @SuppressWarnings({"rawtypes", "unchecked"}) - public NativeQueryImplementor createNativeQuery(String sqlString, Class resultClass, String tableAlias) { - NativeQueryImplementor query = createNativeQuery( sqlString ); + @Override + public NativeQueryImplementor createNativeQuery(String sqlString, Class resultClass, String tableAlias) { + @SuppressWarnings("unchecked") + NativeQueryImplementor query = createNativeQuery( sqlString ); if ( getFactory().getMetamodel().isEntityClass(resultClass) ) { query.addEntity( tableAlias, resultClass.getName(), LockMode.READ ); } @@ -804,9 +805,10 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont return query; } - @Override @SuppressWarnings({"rawtypes", "unchecked"}) - public NativeQueryImplementor createNativeQuery(String sqlString, String resultSetMappingName, Class resultClass) { - final NativeQueryImplementor query = createNativeQuery( sqlString, resultSetMappingName ); + @Override + public NativeQueryImplementor createNativeQuery(String sqlString, String resultSetMappingName, Class resultClass) { + @SuppressWarnings("unchecked") + final NativeQueryImplementor query = createNativeQuery( sqlString, resultSetMappingName ); if ( Tuple.class.equals( resultClass ) ) { query.setTupleTransformer( new NativeQueryTupleTransformer() ); } @@ -1035,11 +1037,11 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont } @Override - public MutationQuery createMutationQuery(CriteriaUpdate updateQuery) { + public MutationQuery createMutationQuery(@SuppressWarnings("rawtypes") CriteriaUpdate updateQuery) { checkOpen(); try { return new QuerySqmImpl<>( - (SqmUpdateStatement) updateQuery, + (SqmUpdateStatement) updateQuery, null, this ); @@ -1050,10 +1052,10 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont } @Override - public MutationQuery createMutationQuery(CriteriaDelete deleteQuery) { + public MutationQuery createMutationQuery(@SuppressWarnings("rawtypes") CriteriaDelete deleteQuery) { checkOpen(); try { - return new QuerySqmImpl( (SqmDeleteStatement) deleteQuery, null, this ); + return new QuerySqmImpl<>( (SqmDeleteStatement) deleteQuery, null, this ); } catch ( RuntimeException e ) { throw getExceptionConverter().convert( e ); @@ -1186,7 +1188,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont } } - @Override @SuppressWarnings("unchecked") + @Override @SuppressWarnings({"unchecked", "rawtypes"}) public QueryImplementor createQuery(@SuppressWarnings("rawtypes") CriteriaUpdate criteriaUpdate) { checkOpen(); try { @@ -1201,7 +1203,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont } } - @Override @SuppressWarnings("unchecked") + @Override @SuppressWarnings({"unchecked", "rawtypes"}) public QueryImplementor createQuery(@SuppressWarnings("rawtypes") CriteriaDelete criteriaDelete) { checkOpen(); try {