How do I set fetch size in JPA? I would like the cursor to read 2000 rows at
once to speed up entity generation. Thanks for help!
--
View this message in context:
For giggles, try this...
- Set the FetchBatchSize to 2000
- Execute your query
- Once you get the result back, iterate over the entire list before you send
it out to your client.
On Mon, Sep 12, 2011 at 2:17 AM, M. Walter marc.wal...@sbb.ch wrote:
How do I set fetch size in JPA? I would like
In my code I would like to set the fetch batch size in order to speed up
loading entities:
final OpenJPAQuery ojpaQuery =
OpenJPAPersistence.cast(em.createNamedQuery(myNiceQuery));
ojpaQuery.getFetchPlan().setFetchBatchSize(2000);
final List result = ojpaQuery.getResultList();
The result list
Does this problem only occur when you set the fetch batch size? I tried
recreating this problem on trunk with a simple unit test where I serialized
a result that came from a cached query and I am unable to see the same
behavior. If I get some time this am I'll give it a shot on 1.2.x.
Thanks,
Yes the problem only occurs if I set the fetch batch size.
I was very astonished getting a
QueryCacheStoreQuery$CachingResultObjectProvider object as result. I would
have expected an OpenJPA implementation of the List interface containing my
entities...
So what is going on here? I don't
I was very astonished getting a
QueryCacheStoreQuery$CachingResultObjectProvider object as result.
I don't think that is quite the case You're getting a List
implementation back, but under the covers OpenJPA is hiding this
CachingResultObjectProvider.
So what is going on here? I don't
Okay thanks. What I was trying to do was setting the fetch size like in
java.sql.ResultSet so rows aren't read one row at a time but many rows at a
time instead. We experienced a higher performance executing a query with
JDBC and using the fetch size feature. Without fetch size the JDBC query was