@@ -158,7 +158,7 @@ public class NativeQueryImpl<R>
158
158
private Callback callback ;
159
159
160
160
/**
161
- * Constructs a NativeQueryImpl given a sql query defined in the mappings.
161
+ * Constructs a {@code NativeQueryImpl} given a SQL query defined in the mappings.
162
162
* Used by Hibernate Reactive.
163
163
*/
164
164
@ SuppressWarnings ("unused" )
@@ -191,7 +191,7 @@ public NativeQueryImpl(NamedNativeQueryMemento<?> memento, SharedSessionContract
191
191
}
192
192
193
193
/**
194
- * Constructs a NativeQueryImpl given a sql query defined in the mappings.
194
+ * Constructs a {@code NativeQueryImpl} given a SQL query defined in the mappings.
195
195
*/
196
196
public NativeQueryImpl (
197
197
NamedNativeQueryMemento <?> memento ,
@@ -228,7 +228,7 @@ public NativeQueryImpl(
228
228
}
229
229
230
230
/**
231
- * Constructs a NativeQueryImpl given a sql query defined in the mappings.
231
+ * Constructs a {@code NativeQueryImpl} given a SQL query defined in the mappings.
232
232
*/
233
233
public NativeQueryImpl (
234
234
NamedNativeQueryMemento <?> memento ,
@@ -378,7 +378,7 @@ else if ( Map.class.equals( resultClass ) ) {
378
378
else if ( List .class .equals ( resultClass ) ) {
379
379
return NativeQueryListTransformer .INSTANCE ;
380
380
}
381
- else if ( Object [].class .equals ( resultClass )) {
381
+ else if ( Object [].class .equals ( resultClass ) ) {
382
382
return NativeQueryArrayTransformer .INSTANCE ;
383
383
}
384
384
else if ( resultClass != Object .class ) {
@@ -535,23 +535,26 @@ public Class<R> getResultType() {
535
535
536
536
@ Override
537
537
public NamedNativeQueryMemento <R > toMemento (String name ) {
538
+ final QueryOptions options = getQueryOptions ();
538
539
return new NamedNativeQueryMementoImpl <>(
539
540
name ,
540
- resultType != null ? resultType : extractResultClass ( resultSetMapping ),
541
+ resultType == null
542
+ ? extractResultClass ( resultSetMapping )
543
+ : resultType ,
541
544
sqlString ,
542
545
originalSqlString ,
543
546
resultSetMapping .getMappingIdentifier (),
544
547
querySpaces ,
545
548
isCacheable (),
546
549
getCacheRegion (),
547
550
getCacheMode (),
548
- getQueryOptions () .getFlushMode (),
551
+ options .getFlushMode (),
549
552
isReadOnly (),
550
553
getTimeout (),
551
554
getFetchSize (),
552
555
getComment (),
553
- getQueryOptions () .getLimit ().getFirstRow (),
554
- getQueryOptions () .getLimit ().getMaxRows (),
556
+ options .getLimit ().getFirstRow (),
557
+ options .getLimit ().getMaxRows (),
555
558
getHints ()
556
559
);
557
560
}
@@ -729,16 +732,16 @@ public KeyedResultList<R> getKeyedResultList(KeyedPage<R> page) {
729
732
protected SelectQueryPlan <R > resolveSelectQueryPlan () {
730
733
final ResultSetMapping mapping ;
731
734
if ( resultType != null && resultSetMapping .isDynamic () && resultSetMapping .getNumberOfResultBuilders () == 0 ) {
732
- mapping = ResultSetMapping . resolveResultSetMapping ( originalSqlString , true , getSessionFactory () );
733
-
734
- if ( getSessionFactory () .getMappingMetamodel ().isEntityClass ( resultType ) ) {
735
+ final SessionFactoryImplementor sessionFactory = getSessionFactory ();
736
+ mapping = ResultSetMapping . resolveResultSetMapping ( originalSqlString , true , sessionFactory );
737
+ if ( sessionFactory .getMappingMetamodel ().isEntityClass ( resultType ) ) {
735
738
mapping .addResultBuilder (
736
739
Builders .entityCalculated ( unqualify ( resultType .getName () ), resultType .getName (),
737
- LockMode .READ , getSessionFactory () ) );
740
+ LockMode .READ , sessionFactory ) );
738
741
}
739
742
else if ( !isResultTypeAlwaysAllowed ( resultType )
740
743
&& (!isClass ( resultType ) || hasJavaTypeDescriptor ( resultType )) ) {
741
- mapping .addResultBuilder ( Builders .resultClassBuilder ( resultType , getSessionFactory () .getMappingMetamodel () ) );
744
+ mapping .addResultBuilder ( Builders .resultClassBuilder ( resultType , sessionFactory .getMappingMetamodel () ) );
742
745
}
743
746
}
744
747
else {
@@ -960,12 +963,13 @@ public static int determineBindValueMaxCount(boolean paddingEnabled, int inExprL
960
963
}
961
964
962
965
private SelectInterpretationsKey selectInterpretationsKey (ResultSetMapping resultSetMapping ) {
966
+ final QueryOptions options = getQueryOptions ();
963
967
return new SelectInterpretationsKey (
964
968
getQueryString (),
965
969
resultSetMapping ,
966
970
getSynchronizedQuerySpaces (),
967
- getQueryOptions () .getTupleTransformer (),
968
- getQueryOptions () .getResultListTransformer ()
971
+ options .getTupleTransformer (),
972
+ options .getResultListTransformer ()
969
973
);
970
974
}
971
975
0 commit comments