[jboss-user] [EJB 3.0] - Re: JbossQL and m.createQuery(.. OFFSET 5 LIMIT 23)

laszlo.fogas do-not-reply at jboss.com
Sun Sep 10 09:31:24 EDT 2006


ok, i try again :)

So, i have an object with lots of lazy onetomany relations. I have second level cache enabled(TreeCache). I would like to use pagination with the setfirstresult/maxresult methods.

If i initialize the lazy collections with calling the size method, and use pagination the entity manager generates the limit/offset into the sql query.
(i set the a show sql param to true.)
But this way the cache does not operate as good as i expect: It's slower than dbhitting.

Here comes the sopution:
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=88317
Which says that i should use fetching joins to initialize the collections, because    the implementation likes that much more.. OK i did this.

But than the pagination breaks.. there's no limit and offset in my queries.

The documentation has a funny comment on this:

"Note that the fetch construct may not be used in queries called using scroll() or iterate(). Nor should fetch be used together with setMaxResults() or setFirstResult(). " 

What does this mean? 

Noone faced the same problem before me?

I have tested the cache with the fetching joins: i changed my query (id<10) in order to simulate the case with limit 10 to test the speed.. As the link said the cache working fine.. the query speed decreased after the first loading.

So there are two bugs(?) which prevent me to use EJB3 efficently!!

Any slutions? Workarounds?

regards, Lazlo

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3970607#3970607

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3970607



More information about the jboss-user mailing list