Skip to content

Commit 0a7863e

Browse files
committed
very minor code cleanups to NativeQueryImpl
1 parent b73d381 commit 0a7863e

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeQueryImpl.java

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public class NativeQueryImpl<R>
158158
private Callback callback;
159159

160160
/**
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.
162162
* Used by Hibernate Reactive.
163163
*/
164164
@SuppressWarnings("unused")
@@ -191,7 +191,7 @@ public NativeQueryImpl(NamedNativeQueryMemento<?> memento, SharedSessionContract
191191
}
192192

193193
/**
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.
195195
*/
196196
public NativeQueryImpl(
197197
NamedNativeQueryMemento<?> memento,
@@ -228,7 +228,7 @@ public NativeQueryImpl(
228228
}
229229

230230
/**
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.
232232
*/
233233
public NativeQueryImpl(
234234
NamedNativeQueryMemento<?> memento,
@@ -378,7 +378,7 @@ else if ( Map.class.equals( resultClass ) ) {
378378
else if ( List.class.equals( resultClass ) ) {
379379
return NativeQueryListTransformer.INSTANCE;
380380
}
381-
else if ( Object[].class.equals( resultClass )) {
381+
else if ( Object[].class.equals( resultClass ) ) {
382382
return NativeQueryArrayTransformer.INSTANCE;
383383
}
384384
else if ( resultClass != Object.class ) {
@@ -535,23 +535,26 @@ public Class<R> getResultType() {
535535

536536
@Override
537537
public NamedNativeQueryMemento<R> toMemento(String name) {
538+
final QueryOptions options = getQueryOptions();
538539
return new NamedNativeQueryMementoImpl<>(
539540
name,
540-
resultType != null ? resultType : extractResultClass( resultSetMapping ),
541+
resultType == null
542+
? extractResultClass( resultSetMapping )
543+
: resultType,
541544
sqlString,
542545
originalSqlString,
543546
resultSetMapping.getMappingIdentifier(),
544547
querySpaces,
545548
isCacheable(),
546549
getCacheRegion(),
547550
getCacheMode(),
548-
getQueryOptions().getFlushMode(),
551+
options.getFlushMode(),
549552
isReadOnly(),
550553
getTimeout(),
551554
getFetchSize(),
552555
getComment(),
553-
getQueryOptions().getLimit().getFirstRow(),
554-
getQueryOptions().getLimit().getMaxRows(),
556+
options.getLimit().getFirstRow(),
557+
options.getLimit().getMaxRows(),
555558
getHints()
556559
);
557560
}
@@ -729,16 +732,16 @@ public KeyedResultList<R> getKeyedResultList(KeyedPage<R> page) {
729732
protected SelectQueryPlan<R> resolveSelectQueryPlan() {
730733
final ResultSetMapping mapping;
731734
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 ) ) {
735738
mapping.addResultBuilder(
736739
Builders.entityCalculated( unqualify( resultType.getName() ), resultType.getName(),
737-
LockMode.READ, getSessionFactory() ) );
740+
LockMode.READ, sessionFactory ) );
738741
}
739742
else if ( !isResultTypeAlwaysAllowed( resultType )
740743
&& (!isClass( resultType ) || hasJavaTypeDescriptor( resultType )) ) {
741-
mapping.addResultBuilder( Builders.resultClassBuilder( resultType, getSessionFactory().getMappingMetamodel() ) );
744+
mapping.addResultBuilder( Builders.resultClassBuilder( resultType, sessionFactory.getMappingMetamodel() ) );
742745
}
743746
}
744747
else {
@@ -960,12 +963,13 @@ public static int determineBindValueMaxCount(boolean paddingEnabled, int inExprL
960963
}
961964

962965
private SelectInterpretationsKey selectInterpretationsKey(ResultSetMapping resultSetMapping) {
966+
final QueryOptions options = getQueryOptions();
963967
return new SelectInterpretationsKey(
964968
getQueryString(),
965969
resultSetMapping,
966970
getSynchronizedQuerySpaces(),
967-
getQueryOptions().getTupleTransformer(),
968-
getQueryOptions().getResultListTransformer()
971+
options.getTupleTransformer(),
972+
options.getResultListTransformer()
969973
);
970974
}
971975

0 commit comments

Comments
 (0)