HHH-12795 Remove duplicate code from SessionImpl

SessionImpl.initQueryFromNamedDefinition calls its super implementation
AbstractSharedSessionContract.initQueryFromNamedDefinition, which
already does a lot of the work performed in
SessionImpl.initQueryFromNamedDefinition.
The only difference is that SessionImpl uses hints to set values on the
query, whereas AbstractSharedSessionContract uses direct calls to
setters. But that should produce the same result, since setHint() just
delegates to the setters.

Only one thing was done in SessionImpl but not in
AbstractSharedSessionContract: lock mode handling.
I left it in SessionImpl since moving it to the superclass would also
affect other subclasses such as StatelessSession or OGM sessions, and I
certainly don't want to change any behavior without further
investigation.
This commit is contained in:
Yoann Rodière 2018-07-12 10:45:48 +02:00 committed by Guillaume Smet
parent a0e6d86052
commit 523b29af04
1 changed files with 0 additions and 39 deletions

View File

@ -3732,41 +3732,6 @@ public final class SessionImpl
protected void initQueryFromNamedDefinition(Query query, NamedQueryDefinition namedQueryDefinition) { protected void initQueryFromNamedDefinition(Query query, NamedQueryDefinition namedQueryDefinition) {
super.initQueryFromNamedDefinition( query, namedQueryDefinition ); super.initQueryFromNamedDefinition( query, namedQueryDefinition );
if ( namedQueryDefinition.isCacheable() ) {
query.setHint( QueryHints.HINT_CACHEABLE, true );
if ( namedQueryDefinition.getCacheRegion() != null ) {
query.setHint( QueryHints.HINT_CACHE_REGION, namedQueryDefinition.getCacheRegion() );
}
}
if ( namedQueryDefinition.getCacheMode() != null ) {
query.setHint( QueryHints.HINT_CACHE_MODE, namedQueryDefinition.getCacheMode() );
}
if ( namedQueryDefinition.isReadOnly() ) {
query.setHint( QueryHints.HINT_READONLY, true );
}
if ( namedQueryDefinition.getTimeout() != null ) {
query.setHint( QueryHints.SPEC_HINT_TIMEOUT, namedQueryDefinition.getTimeout() * 1000 );
}
if ( namedQueryDefinition.getFetchSize() != null ) {
query.setHint( QueryHints.HINT_FETCH_SIZE, namedQueryDefinition.getFetchSize() );
}
if ( namedQueryDefinition.getComment() != null ) {
query.setHint( QueryHints.HINT_COMMENT, namedQueryDefinition.getComment() );
}
if ( namedQueryDefinition.getFirstResult() != null ) {
query.setFirstResult( namedQueryDefinition.getFirstResult() );
}
if ( namedQueryDefinition.getMaxResults() != null ) {
query.setMaxResults( namedQueryDefinition.getMaxResults() );
}
if ( namedQueryDefinition.getLockOptions() != null ) { if ( namedQueryDefinition.getLockOptions() != null ) {
if ( namedQueryDefinition.getLockOptions().getLockMode() != null ) { if ( namedQueryDefinition.getLockOptions().getLockMode() != null ) {
query.setLockMode( query.setLockMode(
@ -3774,10 +3739,6 @@ public final class SessionImpl
); );
} }
} }
if ( namedQueryDefinition.getFlushMode() != null ) {
query.setHibernateFlushMode( namedQueryDefinition.getFlushMode() );
}
} }
@Override @Override