You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Miłosz Tylenda <mt...@o2.pl> on 2011/09/12 20:15:12 UTC

Re: Using FetchPlan.setFetchBatchSize() feature leads tojava.io.NotSerializableException

Hello,

It seems that setting openjpa.FetchBatchSize implicitly enables large result set support which is not suitable for your case.

However, chances are you can execute Statement.setFetchSize(int) by extending the DBDictionary you are using, although it needs some typing. As a guidance, see PostgresDictionary.decorate method. It creates a wrapped Connection, which in turn provides wrapped PreparedStatements where you can override methods like executeQuery and inject a call to setFetchSize. Or do it in prepareStatement method of your wrapped Connection.

Let us know how it goes.

Cheers,
Milosz

> 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: http://openjpa.208410.n2.nabble.com/Using-FetchPlan-setFetchBatchSize-feature-leads-to-java-io-NotSerializableException-tp6771824p6782493.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
> 

Re: Using FetchPlan.setFetchBatchSize() feature leads tojava.io.NotSerializableException

Posted by "M. Walter" <ma...@sbb.ch>.
Okay, using the method setFetchBatchSize(int size) works as desired but the
result is not serializable so an exception will occur after trying to send
the result to a remote client. The simple solution to this problem is: copy
the result list content to a new list and send the copy to the client.
That's it.

--
View this message in context: http://openjpa.208410.n2.nabble.com/Using-FetchPlan-setFetchBatchSize-feature-leads-to-java-io-NotSerializableException-tp6771824p6824148.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Using FetchPlan.setFetchBatchSize() feature leads tojava.io.NotSerializableException

Posted by Miłosz Tylenda <mt...@o2.pl>.
Hi again,

Some database drivers might allow you to specify the default fetch size in connection URL or data source definition. For example, Oracle docs say they have a "defaultRowPrefetch" property for this. Of course, this is not specific to OpenJPA / JPA.

Greetings,
Milosz


> Hello,
> 
> It seems that setting openjpa.FetchBatchSize implicitly enables large result set support which is not suitable for your case.
> 
> However, chances are you can execute Statement.setFetchSize(int) by extending the DBDictionary you are using, although it needs some typing. As a guidance, see PostgresDictionary.decorate method. It creates a wrapped Connection, which in turn provides wrapped PreparedStatements where you can override methods like executeQuery and inject a call to setFetchSize. Or do it in prepareStatement method of your wrapped Connection.
> 
> Let us know how it goes.
> 
> Cheers,
> Milosz
> 
> > 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: http://openjpa.208410.n2.nabble.com/Using-FetchPlan-setFetchBatchSize-feature-leads-to-java-io-NotSerializableException-tp6771824p6782493.html
> > Sent from the OpenJPA Users mailing list archive at Nabble.com.
> > 
>