openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Curtis <curti...@gmail.com>
Subject Re: Is there a way to fetch results from a Query with something like a (database) cursor?
Date Mon, 30 May 2011 13:29:57 GMT
Tim -

Take a look at Large Result Sets[1].

[1]
http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_dbsetup_lrs

Thanks,
Rick

On Mon, May 30, 2011 at 7:47 AM, tfriess <tfriess@de.ibm.com> wrote:

> Hello,
> I'm looking for something like a database cursor in OpenJPA and was not
> able
> to find something similar. (I used Google and also searched this mailing
> list/ forum.)
> I have to use OpenJPA 1.2.2.
>
> Using OpenJPAs Query class I can only get a complete list of entities from
> the database at once (using the "getResultList()" method). If there are a
> lots of entities persisted in the table this (a) could need a lots of time
> and (b) loads all the entities into my memory.
> What I'm looking for is something like an iterator/ cursor to the results
> of
> my query where I can get an entity one by one with some kind of
> "getNext()"-method which I then can process before I fetch the next entity
> from my result. I want to avoid holding all the result entities at once in
> a
> List in my memory.
>
> I figured out that I'm able to get a reference to the java.sql.Connection
> class via the OpenJPAPersistence.
> With this instance I'm able to manually send a query to the database using
> the JDBC mechanisms and get a java.sql.ResultSet as result. With this
> ResultSet I can exactly do what I want - iterate over the results of my
> query.
> But the problem here is (a) I'm using OpenJPA internals and not only the
> JPA
> API and (b) I was not able to figure out how to automatically map a
> ResultSet to my real entity class.
>
> Is there a good solution for my problem?
>
> Thank you very much!
>
> Kind regards,
> Tim
>



-- 
*Rick Curtis*

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message