Java Code Examples for org.hibernate.FlushMode#isManualFlushMode()
The following examples show how to use
org.hibernate.FlushMode#isManualFlushMode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SpringSessionSynchronization.java From lemon with Apache License 2.0 | 6 votes |
public void beforeCommit(boolean readOnly) throws DataAccessException { if (!readOnly) { Session session = getCurrentSession(); // Read-write transaction -> flush the Hibernate Session. // Further check: only flush when not FlushMode.MANUAL. if (!FlushMode.isManualFlushMode(session.getFlushMode())) { try { logger.debug("Flushing Hibernate Session on transaction synchronization"); session.flush(); } catch (HibernateException ex) { throw SessionFactoryUtils .convertHibernateAccessException(ex); } } } }
Example 2
Source File: SpringSessionContext.java From lemon with Apache License 2.0 | 5 votes |
public Session currentSession() throws HibernateException { Object value = TransactionSynchronizationManager .getResource(this.sessionFactory); if (value instanceof Session) { return (Session) value; } else if (value instanceof SessionHolder) { SessionHolder sessionHolder = (SessionHolder) value; Session session = sessionHolder.getSession(); if (TransactionSynchronizationManager.isSynchronizationActive() && !sessionHolder.isSynchronizedWithTransaction()) { TransactionSynchronizationManager .registerSynchronization(new SpringSessionSynchronization( sessionHolder, this.sessionFactory)); sessionHolder.setSynchronizedWithTransaction(true); // Switch to FlushMode.AUTO, as we have to assume a thread-bound Session // with FlushMode.MANUAL, which needs to allow flushing within the transaction. FlushMode flushMode = session.getFlushMode(); if (FlushMode.isManualFlushMode(flushMode) && !TransactionSynchronizationManager .isCurrentTransactionReadOnly()) { session.setFlushMode(FlushMode.AUTO); sessionHolder.setPreviousFlushMode(flushMode); } } return session; } else { throw new HibernateException("No Session found for current thread"); } }
Example 3
Source File: SessionImpl.java From lams with GNU General Public License v2.0 | 4 votes |
private boolean isFlushModeNever() { return FlushMode.isManualFlushMode( getHibernateFlushMode() ); }
Example 4
Source File: SessionImpl.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
public boolean isFlushModeNever() { return FlushMode.isManualFlushMode( getFlushMode() ); }