Here are the examples of the java api org.hibernate.Session.setHibernateFlushMode() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
5 Examples
17
Source : HibernateUtilsTest.java
with Apache License 2.0
from IBM
with Apache License 2.0
from IBM
@ParameterizedTest
@MethodSource("flushModeArguments")
public void testFlushMode(FlushMode previous, TransactionDefinition definition, FlushMode returned, FlushMode settled) {
Session session = factory.openSession();
session.setHibernateFlushMode(previous);
FlushMode result = HibernateUtils.setFlushMode(session, definition);
replacedertEquals(result, returned);
replacedertEquals(session.getHibernateFlushMode(), settled);
}
17
Source : HibernateUtils.java
with Apache License 2.0
from IBM
with Apache License 2.0
from IBM
public static void resetFlushMode(@NonNull Session session, FlushMode flushMode) {
session.setHibernateFlushMode(flushMode);
}
16
Source : HibernateFilter.java
with Apache License 2.0
from openequella
with Apache License 2.0
from openequella
/**
* Prior to hibernate 5, oEQ never touched the FlushMode. Due to changes in Spring and Hibernate,
* `openSession` was added and followed the flow of the Spring impl of `openSession`.
*
* <p>FlushMode is set to MANUAL to reduce surprise flushes to the database, and it'll switch to
* AUTO in a non-read-only transaction, and then flip back.
*
* <p>The internal transaction handling logic with respect to flush mode appears to remain
* unchanged
*
* @param sessionFactory
* @return
*/
private Session openSession(SessionFactory sessionFactory) {
Session session = sessionFactory.openSession();
session.setHibernateFlushMode(FlushMode.MANUAL);
return session;
}
16
Source : BaseSpringTest.java
with BSD 3-Clause "New" or "Revised" License
from dhis2
with BSD 3-Clause "New" or "Revised" License
from dhis2
protected void bindSession() {
SessionFactory sessionFactory = (SessionFactory) applicationContext.getBean("sessionFactory");
Session session = sessionFactory.openSession();
session.setHibernateFlushMode(FlushMode.AUTO);
TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session));
}
15
Source : HibernateUtils.java
with Apache License 2.0
from IBM
with Apache License 2.0
from IBM
public static FlushMode setFlushMode(@NonNull Session session, @NonNull TransactionDefinition transactionDefinition) {
FlushMode previousFlushMode = session.getHibernateFlushMode();
if (transactionDefinition.isReadonly() && needChangeFlushModeForReadOnly(previousFlushMode)) {
session.setHibernateFlushMode(FlushMode.MANUAL);
return previousFlushMode;
} else if (!transactionDefinition.isReadonly() && needChangeFlushMode(previousFlushMode)) {
session.setHibernateFlushMode(FlushMode.AUTO);
return previousFlushMode;
}
return null;
}