Skip to content

Commit 2c30195

Browse files
committed
remove two additional deprecated methods in SharedSessionContractImplementor
1 parent 2462468 commit 2c30195

File tree

6 files changed

+12
-51
lines changed

6 files changed

+12
-51
lines changed

hibernate-core/src/main/java/org/hibernate/engine/spi/SessionDelegatorBaseImpl.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -374,16 +374,6 @@ public boolean isOpenOrWaitingForAutoClose() {
374374
return delegate.isOpenOrWaitingForAutoClose();
375375
}
376376

377-
@Override
378-
public boolean shouldAutoClose() {
379-
return delegate.shouldAutoClose();
380-
}
381-
382-
@Override
383-
public boolean isAutoCloseSessionEnabled() {
384-
return delegate.isAutoCloseSessionEnabled();
385-
}
386-
387377
@Override
388378
public boolean shouldAutoJoinTransaction() {
389379
return delegate.shouldAutoJoinTransaction();

hibernate-core/src/main/java/org/hibernate/engine/spi/SharedSessionContractImplementor.java

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import org.hibernate.LockOptions;
1818
import org.hibernate.StatelessSession;
1919
import org.hibernate.action.spi.AfterTransactionCompletionProcess;
20-
import org.hibernate.boot.spi.SessionFactoryOptions;
2120
import org.hibernate.dialect.Dialect;
2221
import org.hibernate.event.spi.EventSource;
2322
import org.hibernate.query.Query;
@@ -416,26 +415,6 @@ default EventSource asEventSource() {
416415
*/
417416
void afterScrollOperation();
418417

419-
/**
420-
* Should this session be automatically closed after the current
421-
* transaction completes?
422-
*
423-
* @deprecated there's no reason to expose this here
424-
*/
425-
@Deprecated(since = "6")
426-
boolean shouldAutoClose();
427-
428-
/**
429-
* Is auto-close at transaction completion enabled?
430-
*
431-
* @see org.hibernate.cfg.AvailableSettings#AUTO_CLOSE_SESSION
432-
* @see SessionFactoryOptions#isAutoCloseSessionEnabled()
433-
*
434-
* @deprecated there's no reason to expose this here
435-
*/
436-
@Deprecated(since = "6")
437-
boolean isAutoCloseSessionEnabled();
438-
439418
/**
440419
* Get the {@link LoadQueryInfluencers} associated with this session.
441420
*

hibernate-core/src/main/java/org/hibernate/engine/spi/SharedSessionDelegatorBaseImpl.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -528,16 +528,6 @@ public void afterScrollOperation() {
528528
delegate.afterScrollOperation();
529529
}
530530

531-
@Override
532-
public boolean shouldAutoClose() {
533-
return delegate.shouldAutoClose();
534-
}
535-
536-
@Override
537-
public boolean isAutoCloseSessionEnabled() {
538-
return delegate.isAutoCloseSessionEnabled();
539-
}
540-
541531
@Override
542532
public LoadQueryInfluencers getLoadQueryInfluencers() {
543533
return delegate.getLoadQueryInfluencers();

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import jakarta.persistence.metamodel.EntityType;
3030
import org.hibernate.*;
3131
import org.hibernate.action.spi.AfterTransactionCompletionProcess;
32+
import org.hibernate.boot.spi.SessionFactoryOptions;
3233
import org.hibernate.bytecode.enhance.spi.interceptor.EnhancementAsProxyLazinessInterceptor;
3334
import org.hibernate.collection.spi.PersistentCollection;
3435
import org.hibernate.engine.internal.PersistenceContexts;
@@ -482,7 +483,10 @@ protected boolean shouldCloseJdbcCoordinatorOnClose(boolean isTransactionCoordin
482483
return !isTransactionCoordinatorShared;
483484
}
484485

485-
@Override
486+
/**
487+
* Should this session be automatically closed after the current
488+
* transaction completes?
489+
*/
486490
public boolean isAutoCloseSessionEnabled() {
487491
return autoClose;
488492
}
@@ -521,7 +525,6 @@ private void managedFlush() {
521525
}
522526
}
523527

524-
@Override
525528
public boolean shouldAutoClose() {
526529
if ( waitingForAutoClose ) {
527530
return true;
@@ -2198,7 +2201,7 @@ public SharedSessionBuilderImpl connectionHandlingMode() {
21982201

21992202
@Override
22002203
public SharedSessionBuilderImpl autoJoinTransactions() {
2201-
super.autoJoinTransactions( session.isAutoCloseSessionEnabled() );
2204+
super.autoJoinTransactions( session.shouldAutoJoinTransaction() );
22022205
return this;
22032206
}
22042207

@@ -2222,7 +2225,7 @@ public SharedSessionBuilderImpl flushMode() {
22222225

22232226
@Override
22242227
public SharedSessionBuilderImpl autoClose() {
2225-
autoClose( session.autoClose );
2228+
autoClose( session.isAutoCloseSessionEnabled() );
22262229
return this;
22272230
}
22282231

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,12 +1116,10 @@ public Object getIdentifier(Object entity) {
11161116
return getFactory().getPersistenceUnitUtil().getIdentifier(entity);
11171117
}
11181118

1119-
@Override
11201119
public boolean isAutoCloseSessionEnabled() {
11211120
return getSessionFactoryOptions().isAutoCloseSessionEnabled();
11221121
}
11231122

1124-
@Override
11251123
public boolean shouldAutoClose() {
11261124
return isAutoCloseSessionEnabled() && !isClosed();
11271125
}

hibernate-core/src/test/java/org/hibernate/orm/test/sharedSession/SessionWithSharedConnectionTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.hibernate.event.spi.EventType;
1313
import org.hibernate.event.spi.PostInsertEvent;
1414
import org.hibernate.event.spi.PostInsertEventListener;
15+
import org.hibernate.internal.SessionImpl;
1516
import org.hibernate.persister.entity.EntityPersister;
1617

1718
import org.hibernate.resource.jdbc.spi.JdbcSessionOwner;
@@ -95,8 +96,8 @@ public void testSharedTransactionContextAutoClosing(SessionFactoryScope scope) {
9596
.openSession();
9697

9798
// directly assert state of the second session
98-
assertTrue( ((SessionImplementor) secondSession).isAutoCloseSessionEnabled() );
99-
assertTrue( ((SessionImplementor) secondSession).shouldAutoClose() );
99+
assertTrue( ((SessionImpl) secondSession).isAutoCloseSessionEnabled() );
100+
assertTrue( ((SessionImpl) secondSession).shouldAutoClose() );
100101

101102
// now commit the transaction and make sure that does not close the sessions
102103
session.getTransaction().commit();
@@ -119,8 +120,8 @@ public void testSharedTransactionContextAutoClosing(SessionFactoryScope scope) {
119120
.openSession();
120121

121122
// directly assert state of the second session
122-
assertTrue( ((SessionImplementor) secondSession).isAutoCloseSessionEnabled() );
123-
assertTrue( ((SessionImplementor) secondSession).shouldAutoClose() );
123+
assertTrue( ((SessionImpl) secondSession).isAutoCloseSessionEnabled() );
124+
assertTrue( ((SessionImpl) secondSession).shouldAutoClose() );
124125

125126
// now rollback the transaction and make sure that does not close the sessions
126127
session.getTransaction().rollback();

0 commit comments

Comments
 (0)