Code example for Session

Methods: getFlushModesetFlushMode

0
	 * @see org.hibernate.Session#setFlushMode 
	 */ 
	protected FlushMode applyFlushMode(Session session, boolean existingTransaction) { 
		if (getFlushMode() == FLUSH_NEVER) { 
			if (existingTransaction) { 
				FlushMode previousFlushMode = session.getFlushMode(); 
				if (!previousFlushMode.lessThan(FlushMode.COMMIT)) { 
					session.setFlushMode(FlushMode.MANUAL); 
					return previousFlushMode; 
				} 
			} 
			else { 
				session.setFlushMode(FlushMode.MANUAL); 
			} 
		} 
		else if (getFlushMode() == FLUSH_EAGER) { 
			if (existingTransaction) { 
				FlushMode previousFlushMode = session.getFlushMode(); 
				if (!previousFlushMode.equals(FlushMode.AUTO)) { 
					session.setFlushMode(FlushMode.AUTO); 
					return previousFlushMode; 
				} 
			} 
			else { 
				// rely on default FlushMode.AUTO 
			} 
		} 
		else if (getFlushMode() == FLUSH_COMMIT) { 
			if (existingTransaction) { 
				FlushMode previousFlushMode = session.getFlushMode(); 
				if (previousFlushMode.equals(FlushMode.AUTO) || previousFlushMode.equals(FlushMode.ALWAYS)) { 
					session.setFlushMode(FlushMode.COMMIT); 
					return previousFlushMode; 
				} 
			} 
			else { 
				session.setFlushMode(FlushMode.COMMIT); 
			} 
		} 
		else if (getFlushMode() == FLUSH_ALWAYS) { 
			if (existingTransaction) { 
				FlushMode previousFlushMode = session.getFlushMode(); 
				if (!previousFlushMode.equals(FlushMode.ALWAYS)) { 
					session.setFlushMode(FlushMode.ALWAYS); 
					return previousFlushMode; 
				} 
			} 
			else { 
				session.setFlushMode(FlushMode.ALWAYS); 
			} 
		} 
		return null; 
	}