Java Code Examples for org.hibernate.FlushMode#AUTO

The following examples show how to use org.hibernate.FlushMode#AUTO . 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: QueryBinder.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private static FlushMode getFlushMode(FlushModeType flushModeType) {
	FlushMode flushMode;
	switch ( flushModeType ) {
		case ALWAYS:
			flushMode = FlushMode.ALWAYS;
			break;
		case AUTO:
			flushMode = FlushMode.AUTO;
			break;
		case COMMIT:
			flushMode = FlushMode.COMMIT;
			break;
		case NEVER:
			flushMode = FlushMode.MANUAL;
			break;
		case MANUAL:
			flushMode = FlushMode.MANUAL;
			break;
		case PERSISTENCE_CONTEXT:
			flushMode = null;
			break;
		default:
			throw new AssertionFailure( "Unknown flushModeType: " + flushModeType );
	}
	return flushMode;
}
 
Example 2
Source File: NativeQueryImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private boolean shouldFlush() {
	if ( getProducer().isTransactionInProgress() ) {
		FlushMode effectiveFlushMode = getHibernateFlushMode();
		if ( effectiveFlushMode == null ) {
			effectiveFlushMode = getProducer().getHibernateFlushMode();
		}

		if ( effectiveFlushMode == FlushMode.ALWAYS ) {
			return true;
		}

		if ( effectiveFlushMode == FlushMode.AUTO ) {
			if ( getProducer().getFactory().getSessionFactoryOptions().isJpaBootstrap() ) {
				return true;
			}
		}
	}

	return false;
}
 
Example 3
Source File: FlushModeTypeHelper.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public static FlushModeType getFlushModeType(FlushMode flushMode) {
	if ( flushMode == FlushMode.ALWAYS ) {
		log.debug( "Interpreting Hibernate FlushMode#ALWAYS to JPA FlushModeType#AUTO; may cause problems if relying on FlushMode#ALWAYS-specific behavior" );
		return FlushModeType.AUTO;
	}
	else if ( flushMode == FlushMode.MANUAL ) {
		log.debug( "Interpreting Hibernate FlushMode#MANUAL to JPA FlushModeType#COMMIT; may cause problems if relying on FlushMode#MANUAL-specific behavior" );
		return FlushModeType.COMMIT;
	}
	else if ( flushMode == FlushMode.COMMIT ) {
		return FlushModeType.COMMIT;
	}
	else if ( flushMode == FlushMode.AUTO ) {
		return FlushModeType.AUTO;
	}

	throw new AssertionFailure( "unhandled FlushMode " + flushMode );
}
 
Example 4
Source File: FlushModeTypeHelper.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public static FlushMode interpretFlushMode(Object value) {
	if ( value == null ) {
		return FlushMode.AUTO;
	}
	if ( FlushMode.class.isInstance( value ) ) {
		return (FlushMode) value;
	}
	else if ( FlushModeType.class.isInstance( value ) ) {
		return getFlushMode( (FlushModeType) value );
	}
	else if ( String.class.isInstance( value ) ) {
		return interpretExternalSetting( (String) value );
	}

	throw new IllegalArgumentException( "Unknown FlushMode source : " + value );

}
 
Example 5
Source File: SessionFactoryImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
SessionBuilderImpl(SessionFactoryImpl sessionFactory) {
	this.sessionFactory = sessionFactory;
	this.sessionOwner = null;

	// set up default builder values...
	this.statementInspector = sessionFactory.getSessionFactoryOptions().getStatementInspector();
	this.connectionHandlingMode = sessionFactory.getSessionFactoryOptions().getPhysicalConnectionHandlingMode();
	this.autoClose = sessionFactory.getSessionFactoryOptions().isAutoCloseSessionEnabled();
	this.flushMode = sessionFactory.getSessionFactoryOptions().isFlushBeforeCompletionEnabled()
			? FlushMode.AUTO
			: FlushMode.MANUAL;

	if ( sessionFactory.getCurrentTenantIdentifierResolver() != null ) {
		tenantIdentifier = sessionFactory.getCurrentTenantIdentifierResolver().resolveCurrentTenantIdentifier();
	}
	this.jdbcTimeZone = sessionFactory.getSessionFactoryOptions().getJdbcTimeZone();

	listeners = sessionFactory.getSessionFactoryOptions().getBaselineSessionEventsListenerBuilder().buildBaselineList();
	queryParametersValidationEnabled = sessionFactory.getSessionFactoryOptions().isQueryParametersValidationEnabled();
}
 
Example 6
Source File: FlushModeConverter.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public static FlushMode fromXml(String name) {
	// valid values are a subset of all FlushMode possibilities, so we will
	// handle the conversion here directly.
	// Also, we want to map "never"->MANUAL (rather than NEVER)
	if ( name == null ) {
		return null;
	}

	if ( "never".equalsIgnoreCase( name ) ) {
		return FlushMode.MANUAL;
	}
	else if ( "auto".equalsIgnoreCase( name ) ) {
		return FlushMode.AUTO;
	}
	else if ( "always".equalsIgnoreCase( name ) ) {
		return FlushMode.ALWAYS;
	}

	// if the incoming value was not null *and* was not one of the pre-defined
	// values, we need to throw an exception.  This *should never happen if the
	// document we are processing conforms to the schema...
	throw new HibernateException( "Unrecognized flush mode : " + name );
}
 
Example 7
Source File: HbmBinder.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static final FlushMode getFlushMode(String flushMode) {
	if ( flushMode == null ) {
		return null;
	}
	else if ( "auto".equals( flushMode ) ) {
		return FlushMode.AUTO;
	}
	else if ( "commit".equals( flushMode ) ) {
		return FlushMode.COMMIT;
	}
	else if ( "never".equals( flushMode ) ) {
		return FlushMode.NEVER;
	}
	else if ( "manual".equals( flushMode ) ) {
		return FlushMode.MANUAL;
	}
	else if ( "always".equals( flushMode ) ) {
		return FlushMode.ALWAYS;
	}
	else {
		throw new MappingException( "unknown flushmode" );
	}
}
 
Example 8
Source File: MutinySessionImpl.java    From hibernate-reactive with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public FlushMode getFlushMode() {
	switch ( delegate.getHibernateFlushMode() ) {
		case MANUAL:
			return FlushMode.MANUAL;
		case COMMIT:
			return FlushMode.COMMIT;
		case AUTO:
			return FlushMode.AUTO;
		case ALWAYS:
			return FlushMode.ALWAYS;
		default:
			throw new IllegalStateException("impossible flush mode");
	}
}
 
Example 9
Source File: StageSessionImpl.java    From hibernate-reactive with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public FlushMode getFlushMode() {
	switch ( delegate.getHibernateFlushMode() ) {
		case MANUAL:
			return FlushMode.MANUAL;
		case COMMIT:
			return FlushMode.COMMIT;
		case AUTO:
			return FlushMode.AUTO;
		case ALWAYS:
			return FlushMode.ALWAYS;
		default:
			throw new IllegalStateException("impossible flush mode");
	}
}
 
Example 10
Source File: ConfigurationHelper.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private static FlushMode getFlushMode(FlushModeType flushMode)  {
	switch(flushMode) {
		case AUTO:
			return FlushMode.AUTO;
		case COMMIT:
			return FlushMode.COMMIT;
		default:
			throw new AssertionFailure("Unknown FlushModeType: " + flushMode);
	}
}
 
Example 11
Source File: FlushModeTypeHelper.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public static FlushMode getFlushMode(FlushModeType flushModeType) {
	if ( flushModeType == FlushModeType.AUTO ) {
		return FlushMode.AUTO;
	}
	else if ( flushModeType == FlushModeType.COMMIT ) {
		return FlushMode.COMMIT;
	}

	throw new AssertionFailure( "unhandled FlushModeType " + flushModeType );
}