findAll and Collection result optimization
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Chris_Chris
Posted On:   Sunday, July 11, 2004 02:01 PM

Hi, I'm using JBoss 3.2.4 (EJB CMP 2.0) and MySQL 4.0.17. I have to display a list of records from a database using a JSP, in a friendly way. An easy solution would be a findAll (CMP) using an EJB QL query like : SELECT OBJECT(a) FROM App a . The result is a Collection with all the selected records from the database. This way might lead to an OutOfMemoyException because of the great number of records in the database. Any idea for creating a Collection from a "SELECT *" like query without loading all the stored elements from the database (a kind of cursor I would be able to move according to the number of records to fetch. A fetch by page in a w   More>>

Hi,

I'm using JBoss 3.2.4 (EJB CMP 2.0) and MySQL 4.0.17.
I have to display a list of records from a database using a JSP, in a friendly way.

An easy solution would be a findAll (CMP) using an EJB QL query like :

SELECT OBJECT(a) FROM App a .

The result is a Collection with all the selected records from the database.

This way might lead to an OutOfMemoyException because of the great number of records in the database.

Any idea for creating a Collection from a "SELECT *" like query without loading all the stored elements from the database (a kind of cursor I would be able to move according to the number of records to fetch. A fetch by page in a way, using EJB CMP)?



Thanks



Chris

   <<Less

Re: findAll and Collection result optimization

Posted By:   Chris_Chris  
Posted On:   Monday, July 12, 2004 03:46 PM

Now let me answer my question. Yes, it is possible to fetch data from MySQL using the LIMIT clause.

'SELECT ... FROM ... LIMIT start, size', where start is the position of the first database record (eg 0) and size is the size of the page (eg 20).

To bad for me I can't use it from a CMP entity because CMP 2.0 (even 2.1) can't manage it(Error compiling EJB-QL statement) :(:(

Any idea is welcome (before I start using BMP instead).



Thanks



Chris

About | Sitemap | Contact