1 Reply Latest reply on Nov 13, 2006 11:47 AM by mjek2

    Does setMaxResults() has effects on the query?

    heinrich

      Hi,
      i was wondering how
      em.createNamedQuery("MyQuery").setMaxResults(10)
      effects the underlying queries produced by JBoss.

      I fugured out, that at first the complete query is executed and all entities for that query is loaded into the cache and after this the first 10 results are picked and returned.
      Is this right?

      If it it so, how can i afford it that only the first results are selected from the database without loading all the other rows? In my case this issue is a enormouse perfomnce killer.

      I had a look at the annotation
      @BatchSize from Hibernate
      but this is only for specifying the amount of Statements to select one row.

      I'm using JBoss 4.0.3SP1
      EJB3.0
      Postgres7.4

      Thanks for your answers
      and merry christmas


      martin