[hibernate-commits] Hibernate SVN: r17543 - core/trunk/entitymanager/src/main/java/org/hibernate/ejb.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Fri Sep 25 07:14:51 EDT 2009


Author: epbernard
Date: 2009-09-25 07:14:51 -0400 (Fri, 25 Sep 2009)
New Revision: 17543

Modified:
   core/trunk/entitymanager/src/main/java/org/hibernate/ejb/QueryImpl.java
Log:
HHH-4463 do not alter setMaxResult for native queries in getSingleResult() as the query transformation will likely fail.

Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/QueryImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/QueryImpl.java	2009-09-25 09:47:20 UTC (rev 17542)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/QueryImpl.java	2009-09-25 11:14:51 UTC (rev 17543)
@@ -51,6 +51,7 @@
 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 @@
 			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
 			}



More information about the hibernate-commits mailing list