From 13527366c92cead1398602d9b2bdb51c6e98a5b4 Mon Sep 17 00:00:00 2001 From: Jan Schatteman Date: Thu, 3 Mar 2022 23:30:21 +0100 Subject: [PATCH] Removed deprecated setFlushMode from Session and SharedSessionContractImplementor Signed-off-by: Jan Schatteman --- .../src/main/java/org/hibernate/Session.java | 21 +------------------ .../spi/AbstractPersistentCollection.java | 2 +- .../engine/spi/SessionDelegatorBaseImpl.java | 5 ----- .../spi/SharedSessionContractImplementor.java | 18 ---------------- .../AbstractSharedSessionContract.java | 5 ----- .../internal/StatelessSessionImpl.java | 5 ----- .../proxy/AbstractLazyInitializer.java | 2 +- .../orm/test/jpa/EntityManagerTest.java | 2 +- .../hibernate/orm/test/proxy/ProxyTest.java | 2 +- .../integration/flush/AbstractFlushTest.java | 2 +- 10 files changed, 6 insertions(+), 58 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/Session.java b/hibernate-core/src/main/java/org/hibernate/Session.java index 58562ef54d..ced4839cb1 100644 --- a/hibernate-core/src/main/java/org/hibernate/Session.java +++ b/hibernate-core/src/main/java/org/hibernate/Session.java @@ -117,7 +117,7 @@ public interface Session extends SharedSessionContract, EntityManager { /** * Force this session to flush. Must be called at the end of a unit of work, * before the transaction is committed. Depending on the current - * {@link #setFlushMode(FlushMode) flush mode}, the session might automatically + * {@link #setHibernateFlushMode(FlushMode)} flush mode}, the session might automatically * flush when {@link Transaction#commit()} is called, and it is not necessary * to call this method directly. *

@@ -128,25 +128,6 @@ public interface Session extends SharedSessionContract, EntityManager { */ void flush(); - /** - * Set the current {@link FlushMode flush mode} for this session. - *

- * Flushing is the process of synchronizing the underlying persistent - * store with persistable state held in memory. The current flush mode determines - * when the session is automatically flushed. - *

- * The {@link FlushMode#AUTO default flush mode} is sometimes unnecessarily - * aggressive. For a logically "read only" session, it's reasonable to set the - * session's flush mode to {@link FlushMode#MANUAL} at the start of the session - * in order to avoid some unnecessary work. - * - * @param flushMode the new {@link FlushMode} - * - * @deprecated use {@link #setHibernateFlushMode(FlushMode)} - */ - @Deprecated(since="5.2") - void setFlushMode(FlushMode flushMode); - /** * Set the current {@link FlushModeType JPA flush mode} for this session. *

diff --git a/hibernate-core/src/main/java/org/hibernate/collection/spi/AbstractPersistentCollection.java b/hibernate-core/src/main/java/org/hibernate/collection/spi/AbstractPersistentCollection.java index d48407ee15..dcfda12a09 100644 --- a/hibernate-core/src/main/java/org/hibernate/collection/spi/AbstractPersistentCollection.java +++ b/hibernate-core/src/main/java/org/hibernate/collection/spi/AbstractPersistentCollection.java @@ -278,7 +278,7 @@ public abstract class AbstractPersistentCollection implements Serializable, P final SessionFactoryImplementor sf = SessionFactoryRegistry.INSTANCE.getSessionFactory( sessionFactoryUuid ); final SharedSessionContractImplementor session = (SharedSessionContractImplementor) sf.openSession(); session.getPersistenceContextInternal().setDefaultReadOnly( true ); - session.setFlushMode( FlushMode.MANUAL ); + session.setHibernateFlushMode( FlushMode.MANUAL ); return session; } diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionDelegatorBaseImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionDelegatorBaseImpl.java index 251e36f7b8..ec1e3f6ca8 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionDelegatorBaseImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionDelegatorBaseImpl.java @@ -264,11 +264,6 @@ public class SessionDelegatorBaseImpl implements SessionImplementor { return delegate.getHibernateFlushMode(); } - @Override - public void setFlushMode(FlushMode fm) { - delegate.setHibernateFlushMode( fm ); - } - @Override public void lock(Object entity, LockModeType lockMode) { delegate.lock( entity, lockMode ); diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/SharedSessionContractImplementor.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/SharedSessionContractImplementor.java index 0927a02560..c7b1e8ebf7 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/SharedSessionContractImplementor.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/SharedSessionContractImplementor.java @@ -336,24 +336,6 @@ public interface SharedSessionContractImplementor boolean isCriteriaCopyTreeEnabled(); - /** - * Set the flush mode for this session. - *

- * The flush mode determines the points at which the session is flushed. - * Flushing is the process of synchronizing the underlying persistent - * store with persistable state held in memory. - *

- * For a logically "read only" session, it is reasonable to set the session's - * flush mode to {@link FlushMode#MANUAL} at the start of the session (in - * order to achieve some extra performance). - * - * @param flushMode the new flush mode - * - * @deprecated use {@link #setHibernateFlushMode(FlushMode)} instead - */ - @Deprecated(since = "5.2") - void setFlushMode(FlushMode flushMode); - /** * Get the flush mode for this session. *

diff --git a/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java b/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java index 7d5b7b125a..ebd10afca1 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java @@ -615,11 +615,6 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont return getFactory().getJdbcServices(); } - @Override - public void setFlushMode(FlushMode flushMode) { - setHibernateFlushMode( flushMode ); - } - @Override public FlushModeType getFlushMode() { checkOpen(); diff --git a/hibernate-core/src/main/java/org/hibernate/internal/StatelessSessionImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/StatelessSessionImpl.java index c17ecfef7d..3229a7d415 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/StatelessSessionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/StatelessSessionImpl.java @@ -503,11 +503,6 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen throw new UnsupportedOperationException(); } - @Override - public void setFlushMode(FlushMode fm) { - throw new UnsupportedOperationException(); - } - @Override public void setHibernateFlushMode(FlushMode flushMode) { throw new UnsupportedOperationException(); diff --git a/hibernate-core/src/main/java/org/hibernate/proxy/AbstractLazyInitializer.java b/hibernate-core/src/main/java/org/hibernate/proxy/AbstractLazyInitializer.java index c10d6d2525..f8a6573ff5 100644 --- a/hibernate-core/src/main/java/org/hibernate/proxy/AbstractLazyInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/proxy/AbstractLazyInitializer.java @@ -196,7 +196,7 @@ public abstract class AbstractLazyInitializer implements LazyInitializer { SessionFactoryImplementor sf = SessionFactoryRegistry.INSTANCE.getSessionFactory( sessionFactoryUuid ); SharedSessionContractImplementor session = (SharedSessionContractImplementor) sf.openSession(); session.getPersistenceContext().setDefaultReadOnly( true ); - session.setFlushMode( FlushMode.MANUAL ); + session.setHibernateFlushMode( FlushMode.MANUAL ); boolean isJTA = session.getTransactionCoordinator().getTransactionCoordinatorBuilder().isJta(); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/EntityManagerTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/EntityManagerTest.java index 984d5bda7c..16409f3e30 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/EntityManagerTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/EntityManagerTest.java @@ -221,7 +221,7 @@ public class EntityManagerTest extends BaseEntityManagerFunctionalTestCase { EntityManager em = getOrCreateEntityManager(); em.setFlushMode( FlushModeType.COMMIT ); assertEquals( FlushModeType.COMMIT, em.getFlushMode() ); - ( (Session) em ).setFlushMode( FlushMode.ALWAYS ); + ( (Session) em ).setHibernateFlushMode( FlushMode.ALWAYS ); assertEquals( em.getFlushMode(), FlushModeType.AUTO ); em.close(); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/proxy/ProxyTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/proxy/ProxyTest.java index c54163b58e..0fd0187191 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/proxy/ProxyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/proxy/ProxyTest.java @@ -470,7 +470,7 @@ public class ProxyTest extends BaseCoreFunctionalTestCase { s.close(); s = openSession(); - s.setFlushMode( FlushMode.MANUAL ); + s.setHibernateFlushMode( FlushMode.MANUAL ); t = s.beginTransaction(); // load the last container as a proxy Container proxy = s.load( Container.class, lastContainerId ); diff --git a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/flush/AbstractFlushTest.java b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/flush/AbstractFlushTest.java index ce85e73d44..470a848d0d 100644 --- a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/flush/AbstractFlushTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/flush/AbstractFlushTest.java @@ -46,6 +46,6 @@ public abstract class AbstractFlushTest extends BaseEnversJPAFunctionalTestCase @Before public void initFlush() throws IOException { Session session = getSession( getEntityManager() ); - session.setFlushMode( getFlushMode() ); + session.setHibernateFlushMode( getFlushMode() ); } }