Java Code Examples for org.hibernate.FlushMode#equals()

The following examples show how to use org.hibernate.FlushMode#equals() . 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: HibernateJpaDialect.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Nullable
protected FlushMode prepareFlushMode(Session session, boolean readOnly) throws PersistenceException {
	FlushMode flushMode = (FlushMode) ReflectionUtils.invokeMethod(getFlushMode, session);
	Assert.state(flushMode != null, "No FlushMode from Session");
	if (readOnly) {
		// We should suppress flushing for a read-only transaction.
		if (!flushMode.equals(FlushMode.MANUAL)) {
			session.setFlushMode(FlushMode.MANUAL);
			return flushMode;
		}
	}
	else {
		// We need AUTO or COMMIT for a non-read-only transaction.
		if (flushMode.lessThan(FlushMode.COMMIT)) {
			session.setFlushMode(FlushMode.AUTO);
			return flushMode;
		}
	}
	// No FlushMode change needed...
	return null;
}
 
Example 2
Source File: HibernateJpaDialect.java    From java-technology-stack with MIT License 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Nullable
protected FlushMode prepareFlushMode(Session session, boolean readOnly) throws PersistenceException {
	FlushMode flushMode = (FlushMode) ReflectionUtils.invokeMethod(getFlushMode, session);
	Assert.state(flushMode != null, "No FlushMode from Session");
	if (readOnly) {
		// We should suppress flushing for a read-only transaction.
		if (!flushMode.equals(FlushMode.MANUAL)) {
			session.setFlushMode(FlushMode.MANUAL);
			return flushMode;
		}
	}
	else {
		// We need AUTO or COMMIT for a non-read-only transaction.
		if (flushMode.lessThan(FlushMode.COMMIT)) {
			session.setFlushMode(FlushMode.AUTO);
			return flushMode;
		}
	}
	// No FlushMode change needed...
	return null;
}
 
Example 3
Source File: HibernateJpaDialect.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
protected FlushMode prepareFlushMode(Session session, boolean readOnly) throws PersistenceException {
	FlushMode flushMode = (FlushMode) ReflectionUtils.invokeMethod(getFlushMode, session);
	if (readOnly) {
		// We should suppress flushing for a read-only transaction.
		if (!flushMode.equals(FlushMode.MANUAL)) {
			session.setFlushMode(FlushMode.MANUAL);
			return flushMode;
		}
	}
	else {
		// We need AUTO or COMMIT for a non-read-only transaction.
		if (flushMode.lessThan(FlushMode.COMMIT)) {
			session.setFlushMode(FlushMode.AUTO);
			return flushMode;
		}
	}
	// No FlushMode change needed...
	return null;
}
 
Example 4
Source File: HibernateJpaDialect.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
protected FlushMode prepareFlushMode(Session session, boolean readOnly) throws PersistenceException {
	FlushMode flushMode = session.getFlushMode();
	if (readOnly) {
		// We should suppress flushing for a read-only transaction.
		if (!flushMode.equals(FlushMode.MANUAL)) {
			session.setFlushMode(FlushMode.MANUAL);
			return flushMode;
		}
	}
	else {
		// We need AUTO or COMMIT for a non-read-only transaction.
		if (flushMode.lessThan(FlushMode.COMMIT)) {
			session.setFlushMode(FlushMode.AUTO);
			return flushMode;
		}
	}
	// No FlushMode change needed...
	return null;
}