Skip to content

Commit 2ef8352

Browse files
committed
remove two additional deprecated methods in SharedSessionContractImplementor
1 parent 818f52c commit 2ef8352

File tree

6 files changed

+43
-52
lines changed

6 files changed

+43
-52
lines changed

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

-10
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

-21
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

-10
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

+38-5
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,38 @@
2727
import jakarta.persistence.PessimisticLockScope;
2828
import jakarta.persistence.Timeout;
2929
import jakarta.persistence.metamodel.EntityType;
30-
import org.hibernate.*;
30+
import org.hibernate.BatchSize;
31+
import org.hibernate.CacheMode;
32+
import org.hibernate.ConnectionAcquisitionMode;
33+
import org.hibernate.ConnectionReleaseMode;
34+
import org.hibernate.EnabledFetchProfile;
35+
import org.hibernate.EntityFilterException;
36+
import org.hibernate.FetchNotFoundException;
37+
import org.hibernate.FlushMode;
38+
import org.hibernate.HibernateException;
39+
import org.hibernate.Interceptor;
40+
import org.hibernate.JDBCException;
41+
import org.hibernate.LobHelper;
42+
import org.hibernate.LockMode;
43+
import org.hibernate.LockOptions;
44+
import org.hibernate.MappingException;
45+
import org.hibernate.MultiIdentifierLoadAccess;
46+
import org.hibernate.NaturalIdLoadAccess;
47+
import org.hibernate.NaturalIdMultiLoadAccess;
48+
import org.hibernate.ObjectDeletedException;
49+
import org.hibernate.ObjectNotFoundException;
50+
import org.hibernate.ReadOnlyMode;
51+
import org.hibernate.ReplicationMode;
52+
import org.hibernate.Session;
53+
import org.hibernate.SessionBuilder;
54+
import org.hibernate.SessionEventListener;
55+
import org.hibernate.SessionException;
56+
import org.hibernate.SharedSessionBuilder;
57+
import org.hibernate.SimpleNaturalIdLoadAccess;
58+
import org.hibernate.Transaction;
59+
import org.hibernate.TypeMismatchException;
60+
import org.hibernate.UnknownProfileException;
61+
import org.hibernate.UnresolvableObjectException;
3162
import org.hibernate.action.spi.AfterTransactionCompletionProcess;
3263
import org.hibernate.bytecode.enhance.spi.interceptor.EnhancementAsProxyLazinessInterceptor;
3364
import org.hibernate.collection.spi.PersistentCollection;
@@ -482,7 +513,10 @@ protected boolean shouldCloseJdbcCoordinatorOnClose(boolean isTransactionCoordin
482513
return !isTransactionCoordinatorShared;
483514
}
484515

485-
@Override
516+
/**
517+
* Should this session be automatically closed after the current
518+
* transaction completes?
519+
*/
486520
public boolean isAutoCloseSessionEnabled() {
487521
return autoClose;
488522
}
@@ -521,7 +555,6 @@ private void managedFlush() {
521555
}
522556
}
523557

524-
@Override
525558
public boolean shouldAutoClose() {
526559
if ( waitingForAutoClose ) {
527560
return true;
@@ -2198,7 +2231,7 @@ public SharedSessionBuilderImpl connectionHandlingMode() {
21982231

21992232
@Override
22002233
public SharedSessionBuilderImpl autoJoinTransactions() {
2201-
super.autoJoinTransactions( session.isAutoCloseSessionEnabled() );
2234+
super.autoJoinTransactions( session.shouldAutoJoinTransaction() );
22022235
return this;
22032236
}
22042237

@@ -2222,7 +2255,7 @@ public SharedSessionBuilderImpl flushMode() {
22222255

22232256
@Override
22242257
public SharedSessionBuilderImpl autoClose() {
2225-
autoClose( session.autoClose );
2258+
autoClose( session.isAutoCloseSessionEnabled() );
22262259
return this;
22272260
}
22282261

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

-2
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

+5-4
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)