HHH-4463 do not alter setMaxResult for native queries in getSingleResult() as the query transformation will likely fail.

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@17543 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Emmanuel Bernard 2009-09-25 11:14:51 +00:00
parent 8eeaaeb286
commit f108c4af92
1 changed files with 4 additions and 1 deletions

View File

@ -51,6 +51,7 @@ import org.hibernate.FlushMode;
import org.hibernate.HibernateException;
import org.hibernate.QueryParameterException;
import org.hibernate.TypeMismatchException;
import org.hibernate.SQLQuery;
import org.hibernate.engine.query.NamedParameterDescriptor;
import org.hibernate.engine.query.OrdinalParameterDescriptor;
import org.hibernate.hql.QueryExecutionRequestException;
@ -230,7 +231,9 @@ public class QueryImpl<X> extends org.hibernate.ejb.AbstractQueryImpl<X> impleme
boolean mucked = false;
// IMPL NOTE : the mucking with max results here is attempting to help the user from shooting themselves
// in the foot in the case where they have a large query by limiting the query results to 2 max
if ( getSpecifiedMaxResults() != 1 ) {
// SQLQuery cannot be safely paginated, leaving the user's choice here.
if ( getSpecifiedMaxResults() != 1 &&
! ( SQLQuery.class.isAssignableFrom( query.getClass() ) ) ) {
mucked = true;
query.setMaxResults( 2 ); //avoid OOME if the list is huge
}