Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Anish Shah
Greenhorn
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
Greenhorn
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic