Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

setMaxResults overwritten by NULL after set to 2 by getSingleResult()

Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried in every different way. Read many many articles, But could not get an answer. Please Help !!!
Problem - maxRows get overwriiten by null(actually they are not copied over) in QueryTranslatorImpl

This is where i create a query and call getSingleResult()

Method getSingleResult which sets the Max result to 2 (code -query.setMaxResults( 2 ) )
and then call query.list() for answer.

Class - org.hibernate.ejb.QueryImpl (JAR - hibernate-entitymanager-3.4.0.GA)

So when getSingleResult is called, it sets the max rows to 2. Now the problem is maxResult always gets overwritten by null.

queryParametersToUse = queryParameters.createCopyUsing( selection ); - this new selection object copies over Fetchsize and Timeout but not maxResults. Hence the new queryParameters does not have value 2.
There is a log warning ( log.warn( "firstResult/maxResults specified with collection fetch; applying in memory!" ); ) about it but i could not understand it.

Class - org.hibernate.hql.ast.QueryTranslatorImpl (JAR -hibernate-core-3.3.1.GA.jar)

Thank you..
Anish Shah
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any ideas guys !!!

Does anyone have any idea on this log message . I think it can lead us to the answer ----

I guess it means - if my query consists of fetch( my query consists of 3 left join fetch), it would not persist over my maxRows result.

I am totally blocked on this issue. Please let me know if anyone has any thoughts, ideas, suggestions on it.

Getting married means "We're in love, so let's tell the police!" - and invite this tiny ad to the wedding:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic