fix some generics warnings

This commit is contained in:
Gavin King 2022-01-22 11:59:06 +01:00
parent ec64ce7321
commit 8a2c000b78
2 changed files with 24 additions and 20 deletions

View File

@ -450,12 +450,12 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
} }
@Override @Override
public MutationQuery createMutationQuery(CriteriaUpdate updateQuery) { public MutationQuery createMutationQuery(@SuppressWarnings("rawtypes") CriteriaUpdate updateQuery) {
return delegate().createMutationQuery( updateQuery ); return delegate().createMutationQuery( updateQuery );
} }
@Override @Override
public MutationQuery createMutationQuery(CriteriaDelete deleteQuery) { public MutationQuery createMutationQuery(@SuppressWarnings("rawtypes") CriteriaDelete deleteQuery) {
return delegate().createMutationQuery( deleteQuery ); return delegate().createMutationQuery( deleteQuery );
} }
@ -464,12 +464,12 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
return queryDelegate().createQuery( criteriaQuery ); return queryDelegate().createQuery( criteriaQuery );
} }
@Override @Override @SuppressWarnings("rawtypes")
public QueryImplementor createQuery(CriteriaUpdate updateQuery) { public QueryImplementor createQuery(CriteriaUpdate updateQuery) {
return queryDelegate().createQuery( updateQuery ); return queryDelegate().createQuery( updateQuery );
} }
@Override @Override @SuppressWarnings("rawtypes")
public QueryImplementor createQuery(CriteriaDelete deleteQuery) { public QueryImplementor createQuery(CriteriaDelete deleteQuery) {
return queryDelegate().createQuery( deleteQuery ); return queryDelegate().createQuery( deleteQuery );
} }
@ -520,12 +520,14 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
} }
@Override @SuppressWarnings({"rawtypes", "unchecked"}) @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) { public NativeQueryImplementor createNativeQuery(String sqlString, Class resultClass) {
return queryDelegate().createNativeQuery( sqlString, resultClass ); return queryDelegate().createNativeQuery( sqlString, resultClass );
} }
@Override @SuppressWarnings({"rawtypes", "unchecked"}) @Override
public NativeQueryImplementor createNativeQuery(String sqlString, Class resultClass, String tableAlias) { public <T> NativeQueryImplementor<T> createNativeQuery(String sqlString, Class<T> resultClass, String tableAlias) {
return queryDelegate().createNativeQuery( sqlString, resultClass, tableAlias ); return queryDelegate().createNativeQuery( sqlString, resultClass, tableAlias );
} }
@ -534,8 +536,8 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
return queryDelegate().createNativeQuery( sqlString, resultSetMappingName ); return queryDelegate().createNativeQuery( sqlString, resultSetMappingName );
} }
@Override @SuppressWarnings({"rawtypes", "unchecked"}) @Override
public NativeQueryImplementor createNativeQuery(String sqlString, String resultSetMappingName, Class resultClass) { public <T> NativeQueryImplementor<T> createNativeQuery(String sqlString, String resultSetMappingName, Class<T> resultClass) {
return queryDelegate().createNativeQuery( sqlString, resultSetMappingName, resultClass ); return queryDelegate().createNativeQuery( sqlString, resultSetMappingName, resultClass );
} }

View File

@ -792,9 +792,10 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
return query; return query;
} }
@Override @SuppressWarnings({"rawtypes", "unchecked"}) @Override
public NativeQueryImplementor createNativeQuery(String sqlString, Class resultClass, String tableAlias) { public <T> NativeQueryImplementor<T> createNativeQuery(String sqlString, Class<T> resultClass, String tableAlias) {
NativeQueryImplementor query = createNativeQuery( sqlString ); @SuppressWarnings("unchecked")
NativeQueryImplementor<T> query = createNativeQuery( sqlString );
if ( getFactory().getMetamodel().isEntityClass(resultClass) ) { if ( getFactory().getMetamodel().isEntityClass(resultClass) ) {
query.addEntity( tableAlias, resultClass.getName(), LockMode.READ ); query.addEntity( tableAlias, resultClass.getName(), LockMode.READ );
} }
@ -804,9 +805,10 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
return query; return query;
} }
@Override @SuppressWarnings({"rawtypes", "unchecked"}) @Override
public NativeQueryImplementor createNativeQuery(String sqlString, String resultSetMappingName, Class resultClass) { public <T> NativeQueryImplementor<T> createNativeQuery(String sqlString, String resultSetMappingName, Class<T> resultClass) {
final NativeQueryImplementor query = createNativeQuery( sqlString, resultSetMappingName ); @SuppressWarnings("unchecked")
final NativeQueryImplementor<T> query = createNativeQuery( sqlString, resultSetMappingName );
if ( Tuple.class.equals( resultClass ) ) { if ( Tuple.class.equals( resultClass ) ) {
query.setTupleTransformer( new NativeQueryTupleTransformer() ); query.setTupleTransformer( new NativeQueryTupleTransformer() );
} }
@ -1035,11 +1037,11 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
} }
@Override @Override
public MutationQuery createMutationQuery(CriteriaUpdate updateQuery) { public MutationQuery createMutationQuery(@SuppressWarnings("rawtypes") CriteriaUpdate updateQuery) {
checkOpen(); checkOpen();
try { try {
return new QuerySqmImpl<>( return new QuerySqmImpl<>(
(SqmUpdateStatement) updateQuery, (SqmUpdateStatement<?>) updateQuery,
null, null,
this this
); );
@ -1050,10 +1052,10 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
} }
@Override @Override
public MutationQuery createMutationQuery(CriteriaDelete deleteQuery) { public MutationQuery createMutationQuery(@SuppressWarnings("rawtypes") CriteriaDelete deleteQuery) {
checkOpen(); checkOpen();
try { try {
return new QuerySqmImpl( (SqmDeleteStatement) deleteQuery, null, this ); return new QuerySqmImpl<>( (SqmDeleteStatement<?>) deleteQuery, null, this );
} }
catch ( RuntimeException e ) { catch ( RuntimeException e ) {
throw getExceptionConverter().convert( 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) { public QueryImplementor createQuery(@SuppressWarnings("rawtypes") CriteriaUpdate criteriaUpdate) {
checkOpen(); checkOpen();
try { 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) { public QueryImplementor createQuery(@SuppressWarnings("rawtypes") CriteriaDelete criteriaDelete) {
checkOpen(); checkOpen();
try { try {