Java Code Examples for org.hibernate.engine.spi.NamedQueryDefinition#getLockOptions()

The following examples show how to use org.hibernate.engine.spi.NamedQueryDefinition#getLockOptions() . 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: AbstractSharedSessionContract.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
protected QueryImplementor createQuery(NamedQueryDefinition queryDefinition) {
		String queryString = queryDefinition.getQueryString();
		final QueryImpl query = new QueryImpl(
				this,
				getQueryPlan( queryString, false ).getParameterMetadata(),
				queryString
		);
		query.setHibernateFlushMode( queryDefinition.getFlushMode() );
		query.setComment( queryDefinition.getComment() != null ? queryDefinition.getComment() : queryDefinition.getName() );
		if ( queryDefinition.getLockOptions() != null ) {
			query.setLockOptions( queryDefinition.getLockOptions() );
		}

		initQueryFromNamedDefinition( query, queryDefinition );
//		applyQuerySettingsAndHints( query );

		return query;
	}
 
Example 2
Source File: ReactiveSessionImpl.java    From hibernate-reactive with GNU Lesser General Public License v2.1 5 votes vote down vote up
private <T> ReactiveQuery<T> createReactiveQuery(NamedQueryDefinition queryDefinition) {
	String queryString = queryDefinition.getQueryString();
	ParameterMetadataImpl paramMetadata = getQueryPlan( queryString, false ).getParameterMetadata();
	ReactiveQueryImpl<T> query = new ReactiveQueryImpl<>( this, paramMetadata, queryString, queryType( queryString ) );
	applyQuerySettingsAndHints( query );
	query.setHibernateFlushMode( queryDefinition.getFlushMode() );
	query.setComment( queryDefinition.getComment() != null ? queryDefinition.getComment() : queryDefinition.getName() );
	if ( queryDefinition.getLockOptions() != null ) {
		query.setLockOptions( queryDefinition.getLockOptions() );
	}

	initQueryFromNamedDefinition( query, queryDefinition );

	return query;
}
 
Example 3
Source File: SessionImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void initQueryFromNamedDefinition(Query query, NamedQueryDefinition namedQueryDefinition) {
	super.initQueryFromNamedDefinition( query, namedQueryDefinition );

	if ( namedQueryDefinition.isCacheable() ) {
		query.setHint( QueryHints.HINT_CACHEABLE, true );
		if ( namedQueryDefinition.getCacheRegion() != null ) {
			query.setHint( QueryHints.HINT_CACHE_REGION, namedQueryDefinition.getCacheRegion() );
		}
	}

	if ( namedQueryDefinition.getCacheMode() != null ) {
		query.setHint( QueryHints.HINT_CACHE_MODE, namedQueryDefinition.getCacheMode() );
	}

	if ( namedQueryDefinition.isReadOnly() ) {
		query.setHint( QueryHints.HINT_READONLY, true );
	}

	if ( namedQueryDefinition.getTimeout() != null ) {
		query.setHint( QueryHints.SPEC_HINT_TIMEOUT, namedQueryDefinition.getTimeout() * 1000 );
	}

	if ( namedQueryDefinition.getFetchSize() != null ) {
		query.setHint( QueryHints.HINT_FETCH_SIZE, namedQueryDefinition.getFetchSize() );
	}

	if ( namedQueryDefinition.getComment() != null ) {
		query.setHint( QueryHints.HINT_COMMENT, namedQueryDefinition.getComment() );
	}

	if ( namedQueryDefinition.getFirstResult() != null ) {
		query.setFirstResult( namedQueryDefinition.getFirstResult() );
	}

	if ( namedQueryDefinition.getMaxResults() != null ) {
		query.setMaxResults( namedQueryDefinition.getMaxResults() );
	}

	if ( namedQueryDefinition.getLockOptions() != null ) {
		if ( namedQueryDefinition.getLockOptions().getLockMode() != null ) {
			query.setLockMode(
					LockModeTypeHelper.getLockModeType( namedQueryDefinition.getLockOptions().getLockMode() )
			);
		}
	}

	if ( namedQueryDefinition.getFlushMode() != null ) {
		query.setHibernateFlushMode( namedQueryDefinition.getFlushMode() );
	}
}