Java Code Examples for org.springframework.orm.hibernate4.SessionFactoryUtils#convertHibernateAccessException()

The following examples show how to use org.springframework.orm.hibernate4.SessionFactoryUtils#convertHibernateAccessException() . 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 vote down vote up
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: SpringSessionSynchronization.java    From lemon with Apache License 2.0 5 votes vote down vote up
public void flush() {
    try {
        logger.debug("Flushing Hibernate Session on explicit request");
        getCurrentSession().flush();
    } catch (HibernateException ex) {
        throw SessionFactoryUtils.convertHibernateAccessException(ex);
    }
}