Skip to content

Commit 523b29a

Browse files
yrodieregsmet
authored andcommitted
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.
1 parent a0e6d86 commit 523b29a

File tree

1 file changed

+0
-39
lines changed

1 file changed

+0
-39
lines changed

hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3732,52 +3732,13 @@ public QueryImplementor createQuery(CriteriaDelete criteriaDelete) {
37323732
protected void initQueryFromNamedDefinition(Query query, NamedQueryDefinition namedQueryDefinition) {
37333733
super.initQueryFromNamedDefinition( query, namedQueryDefinition );
37343734

3735-
if ( namedQueryDefinition.isCacheable() ) {
3736-
query.setHint( QueryHints.HINT_CACHEABLE, true );
3737-
if ( namedQueryDefinition.getCacheRegion() != null ) {
3738-
query.setHint( QueryHints.HINT_CACHE_REGION, namedQueryDefinition.getCacheRegion() );
3739-
}
3740-
}
3741-
3742-
if ( namedQueryDefinition.getCacheMode() != null ) {
3743-
query.setHint( QueryHints.HINT_CACHE_MODE, namedQueryDefinition.getCacheMode() );
3744-
}
3745-
3746-
if ( namedQueryDefinition.isReadOnly() ) {
3747-
query.setHint( QueryHints.HINT_READONLY, true );
3748-
}
3749-
3750-
if ( namedQueryDefinition.getTimeout() != null ) {
3751-
query.setHint( QueryHints.SPEC_HINT_TIMEOUT, namedQueryDefinition.getTimeout() * 1000 );
3752-
}
3753-
3754-
if ( namedQueryDefinition.getFetchSize() != null ) {
3755-
query.setHint( QueryHints.HINT_FETCH_SIZE, namedQueryDefinition.getFetchSize() );
3756-
}
3757-
3758-
if ( namedQueryDefinition.getComment() != null ) {
3759-
query.setHint( QueryHints.HINT_COMMENT, namedQueryDefinition.getComment() );
3760-
}
3761-
3762-
if ( namedQueryDefinition.getFirstResult() != null ) {
3763-
query.setFirstResult( namedQueryDefinition.getFirstResult() );
3764-
}
3765-
3766-
if ( namedQueryDefinition.getMaxResults() != null ) {
3767-
query.setMaxResults( namedQueryDefinition.getMaxResults() );
3768-
}
3769-
37703735
if ( namedQueryDefinition.getLockOptions() != null ) {
37713736
if ( namedQueryDefinition.getLockOptions().getLockMode() != null ) {
37723737
query.setLockMode(
37733738
LockModeTypeHelper.getLockModeType( namedQueryDefinition.getLockOptions().getLockMode() )
37743739
);
37753740
}
37763741
}
3777-
3778-
if ( namedQueryDefinition.getFlushMode() != null ) {
3779-
query.setHibernateFlushMode( namedQueryDefinition.getFlushMode() );
3780-
}
37813742
}
37823743

37833744
@Override

0 commit comments

Comments
 (0)