@@ -277,27 +277,15 @@ public List<X> getResultList() {
277
277
@ SuppressWarnings ({ "unchecked" , "RedundantCast" })
278
278
public X getSingleResult () {
279
279
try {
280
- boolean mucked = false ;
281
- // IMPL NOTE : the mucking with max results here is attempting to help the user from shooting themselves
282
- // in the foot in the case where they have a large query by limiting the query results to 2 max
283
- // SQLQuery cannot be safely paginated, leaving the user's choice here.
284
- if ( getSpecifiedMaxResults () != 1 &&
285
- ! ( SQLQuery .class .isAssignableFrom ( query .getClass () ) ) ) {
286
- mucked = true ;
287
- query .setMaxResults ( 2 ); //avoid OOME if the list is huge
288
- }
289
- List <X > result = query .list ();
290
- if ( mucked ) {
291
- query .setMaxResults ( getSpecifiedMaxResults () );
292
- }
280
+ final List <X > result = query .list ();
293
281
294
282
if ( result .size () == 0 ) {
295
283
NoResultException nre = new NoResultException ( "No entity found for query" );
296
284
getEntityManager ().handlePersistenceException ( nre );
297
285
throw nre ;
298
286
}
299
287
else if ( result .size () > 1 ) {
300
- Set <X > uniqueResult = new HashSet <X >(result );
288
+ final Set <X > uniqueResult = new HashSet <X >(result );
301
289
if ( uniqueResult .size () > 1 ) {
302
290
NonUniqueResultException nure = new NonUniqueResultException ( "result returns more than one elements" );
303
291
getEntityManager ().handlePersistenceException ( nure );
@@ -306,7 +294,6 @@ else if ( result.size() > 1 ) {
306
294
else {
307
295
return uniqueResult .iterator ().next ();
308
296
}
309
-
310
297
}
311
298
else {
312
299
return result .get ( 0 );
0 commit comments