Java Code Examples for org.hibernate.engine.spi.QueryParameters#validateParameters()

The following examples show how to use org.hibernate.engine.spi.QueryParameters#validateParameters() . 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: ReactiveSessionImpl.java    From hibernate-reactive with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
	public <T> CompletionStage<List<T>> reactiveList(String query, QueryParameters parameters) throws HibernateException {
		checkOpenOrWaitingForAutoClose();
		pulseTransactionCoordinator();
		parameters.validateParameters();

		HQLQueryPlan plan = parameters.getQueryPlan();
		if ( plan == null ) {
			plan = getQueryPlan( query, false );
		}
		ReactiveHQLQueryPlan reactivePlan = (ReactiveHQLQueryPlan) plan;

		return reactiveAutoFlushIfRequired( plan.getQuerySpaces() )
				// FIXME: I guess I can fix this as a separate issue
//				dontFlushFromFind++;   //stops flush being called multiple times if this method is recursively called
				.thenCompose( v -> reactivePlan.performReactiveList(parameters, this ) )
				.whenComplete( (list, x) -> {
//					dontFlushFromFind--;
					afterOperation( x == null );
					delayedAfterCompletion();
				} )
				//TODO: this typecast is rubbish
				.thenApply( list -> (List<T>) list );
	}
 
Example 2
Source File: ReactiveSessionImpl.java    From hibernate-reactive with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public CompletionStage<Integer> executeReactiveUpdate(NativeSQLQuerySpecification specification,
													  QueryParameters parameters) {
	checkOpenOrWaitingForAutoClose();
	pulseTransactionCoordinator();
	parameters.validateParameters();

	ReactiveNativeSQLQueryPlan reactivePlan = //getNativeQueryPlan( specification );
			new ReactiveNativeSQLQueryPlan(
					specification.getQueryString(),
					new SQLCustomQuery(
							specification.getQueryString(),
							specification.getQueryReturns(),
							specification.getQuerySpaces(),
							getFactory()
					) );
	return reactiveAutoFlushIfRequired( reactivePlan.getCustomQuery().getQuerySpaces() )
			.thenCompose( v -> reactivePlan.performExecuteReactiveUpdate( parameters, this ) )
			.whenComplete( (count, x) -> {
				afterOperation( x == null );
				delayedAfterCompletion();
			} );
}
 
Example 3
Source File: SessionImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public int executeUpdate(String query, QueryParameters queryParameters) throws HibernateException {
	checkOpenOrWaitingForAutoClose();
	checkTransactionSynchStatus();
	queryParameters.validateParameters();
	HQLQueryPlan plan = getQueryPlan( query, false );
	autoFlushIfRequired( plan.getQuerySpaces() );

	verifyImmutableEntityUpdate( plan );

	boolean success = false;
	int result = 0;
	try {
		result = plan.performExecuteUpdate( queryParameters, this );
		success = true;
	}
	finally {
		afterOperation( success );
		delayedAfterCompletion();
	}
	return result;
}
 
Example 4
Source File: SessionImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public int executeNativeUpdate(
		NativeSQLQuerySpecification nativeQuerySpecification,
		QueryParameters queryParameters) throws HibernateException {
	checkOpenOrWaitingForAutoClose();
	checkTransactionSynchStatus();
	queryParameters.validateParameters();
	NativeSQLQueryPlan plan = getNativeQueryPlan( nativeQuerySpecification );


	autoFlushIfRequired( plan.getCustomQuery().getQuerySpaces() );

	boolean success = false;
	int result = 0;
	try {
		result = plan.performExecuteUpdate( queryParameters, this );
		success = true;
	}
	finally {
		afterOperation( success );
		delayedAfterCompletion();
	}
	return result;
}
 
Example 5
Source File: SessionImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Iterator iterate(String query, QueryParameters queryParameters) throws HibernateException {
	checkOpenOrWaitingForAutoClose();
	checkTransactionSynchStatus();
	queryParameters.validateParameters();

	HQLQueryPlan plan = queryParameters.getQueryPlan();
	if ( plan == null ) {
		plan = getQueryPlan( query, true );
	}

	autoFlushIfRequired( plan.getQuerySpaces() );

	dontFlushFromFind++; //stops flush being called multiple times if this method is recursively called
	try {
		return plan.performIterate( queryParameters, this );
	}
	finally {
		delayedAfterCompletion();
		dontFlushFromFind--;
	}
}
 
Example 6
Source File: StatelessSessionImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public int executeUpdate(String query, QueryParameters queryParameters) throws HibernateException {
	checkOpen();
	queryParameters.validateParameters();
	HQLQueryPlan plan = getQueryPlan( query, false );
	boolean success = false;
	int result = 0;
	try {
		result = plan.performExecuteUpdate( queryParameters, this );
		success = true;
	}
	finally {
		afterOperation( success );
	}
	temporaryPersistenceContext.clear();
	return result;
}
 
Example 7
Source File: StatelessSessionImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public List list(String query, QueryParameters queryParameters) throws HibernateException {
	checkOpen();
	queryParameters.validateParameters();
	HQLQueryPlan plan = getQueryPlan( query, false );
	boolean success = false;
	List results = Collections.EMPTY_LIST;
	try {
		results = plan.performList( queryParameters, this );
		success = true;
	}
	finally {
		afterOperation( success );
	}
	temporaryPersistenceContext.clear();
	return results;
}
 
Example 8
Source File: StatelessSessionImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public int executeNativeUpdate(
		NativeSQLQuerySpecification nativeSQLQuerySpecification,
		QueryParameters queryParameters) throws HibernateException {
	checkOpen();
	queryParameters.validateParameters();
	NativeSQLQueryPlan plan = getNativeQueryPlan( nativeSQLQuerySpecification );

	boolean success = false;
	int result = 0;
	try {
		result = plan.performExecuteUpdate( queryParameters, this );
		success = true;
	}
	finally {
		afterOperation( success );
	}
	temporaryPersistenceContext.clear();
	return result;
}
 
Example 9
Source File: ReactiveSessionImpl.java    From hibernate-reactive with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public CompletionStage<Integer> executeReactiveUpdate(String query, QueryParameters parameters) {
	checkOpenOrWaitingForAutoClose();
	pulseTransactionCoordinator();
	parameters.validateParameters();

	ReactiveHQLQueryPlan reactivePlan = getQueryPlan( query, false );
	return reactiveAutoFlushIfRequired( reactivePlan.getQuerySpaces() )
			.thenAccept( v -> verifyImmutableEntityUpdate( reactivePlan ) )
			.thenCompose( v -> reactivePlan.performExecuteReactiveUpdate( parameters, this ) )
			.whenComplete( (count, x) -> {
				afterOperation( x == null );
				delayedAfterCompletion();
			} );
}
 
Example 10
Source File: SessionImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public List list(String query, QueryParameters queryParameters) throws HibernateException {
	checkOpenOrWaitingForAutoClose();
	checkTransactionSynchStatus();
	queryParameters.validateParameters();

	HQLQueryPlan plan = queryParameters.getQueryPlan();
	if ( plan == null ) {
		plan = getQueryPlan( query, false );
	}

	autoFlushIfRequired( plan.getQuerySpaces() );

	List results = Collections.EMPTY_LIST;
	boolean success = false;

	dontFlushFromFind++;   //stops flush being called multiple times if this method is recursively called
	try {
		results = plan.performList( queryParameters, this );
		success = true;
	}
	finally {
		dontFlushFromFind--;
		afterOperation( success );
		delayedAfterCompletion();
	}
	return results;
}