|
19 | 19 | import java.util.function.Function;
|
20 | 20 |
|
21 | 21 | import jakarta.persistence.EntityGraph;
|
| 22 | +import org.checkerframework.checker.nullness.qual.Nullable; |
22 | 23 | import org.hibernate.CacheMode;
|
23 | 24 | import org.hibernate.EntityNameResolver;
|
24 | 25 | import org.hibernate.Filter;
|
@@ -891,22 +892,8 @@ public <T> QueryImplementor<T> createQuery(String queryString, Class<T> expected
|
891 | 892 | // dynamic native (SQL) query handling
|
892 | 893 |
|
893 | 894 | @Override @SuppressWarnings("rawtypes")
|
894 |
| - public NativeQueryImpl createNativeQuery(String sqlString) { |
895 |
| - checkOpen(); |
896 |
| - pulseTransactionCoordinator(); |
897 |
| - delayedAfterCompletion(); |
898 |
| - |
899 |
| - try { |
900 |
| - final NativeQueryImpl query = new NativeQueryImpl<>( sqlString, this ); |
901 |
| - if ( isEmpty( query.getComment() ) ) { |
902 |
| - query.setComment( "dynamic native SQL query" ); |
903 |
| - } |
904 |
| - applyQuerySettingsAndHints( query ); |
905 |
| - return query; |
906 |
| - } |
907 |
| - catch (RuntimeException he) { |
908 |
| - throw getExceptionConverter().convert( he ); |
909 |
| - } |
| 895 | + public NativeQueryImplementor createNativeQuery(String sqlString) { |
| 896 | + return createNativeQuery( sqlString, (Class) null ); |
910 | 897 | }
|
911 | 898 |
|
912 | 899 | @Override @SuppressWarnings("rawtypes")
|
@@ -939,12 +926,28 @@ protected NamedResultSetMappingMemento getResultSetMappingMemento(String resultS
|
939 | 926 | @Override @SuppressWarnings({"rawtypes", "unchecked"})
|
940 | 927 | //note: we're doing something a bit funny here to work around
|
941 | 928 | // the clashing signatures declared by the supertypes
|
942 |
| - public NativeQueryImplementor createNativeQuery(String sqlString, Class resultClass) { |
943 |
| - final NativeQueryImpl query = createNativeQuery( sqlString ); |
944 |
| - addResultType( resultClass, query ); |
945 |
| - return query; |
| 929 | + public NativeQueryImplementor createNativeQuery(String sqlString, @Nullable Class resultClass) { |
| 930 | + checkOpen(); |
| 931 | + pulseTransactionCoordinator(); |
| 932 | + delayedAfterCompletion(); |
| 933 | + |
| 934 | + try { |
| 935 | + final NativeQueryImpl query = new NativeQueryImpl<>( sqlString, resultClass, this ); |
| 936 | + if ( isEmpty( query.getComment() ) ) { |
| 937 | + query.setComment( "dynamic native SQL query" ); |
| 938 | + } |
| 939 | + applyQuerySettingsAndHints( query ); |
| 940 | + return query; |
| 941 | + } |
| 942 | + catch (RuntimeException he) { |
| 943 | + throw getExceptionConverter().convert( he ); |
| 944 | + } |
946 | 945 | }
|
947 | 946 |
|
| 947 | + /** |
| 948 | + * @deprecated Use {@link NativeQueryImpl#NativeQueryImpl(String, Class, SharedSessionContractImplementor)} instead |
| 949 | + */ |
| 950 | + @Deprecated(forRemoval = true) |
948 | 951 | protected <T> void addResultType(Class<T> resultClass, NativeQueryImplementor<T> query) {
|
949 | 952 | if ( Tuple.class.equals( resultClass ) ) {
|
950 | 953 | query.setTupleTransformer( NativeQueryTupleTransformer.INSTANCE );
|
|
0 commit comments