I think the reason (or maybe just one of them) for the 
query sent is the assumption that you might not read all 
the records all the time but only a few at a time, you 
might even stop reading them in the middle of your 
processing:

Collection c = yourBeanHome.findAll ();
// Suppose this returns 2000 records after executing 
// SQL with no where (id = ?) or (id = ?)
Iterator i = c.iterator ();
int counter = 0;
while (i.hasNext ()) { 
   YourBean yb = (YourBean) i.next ();
   if (counter > 5) { break; }
   counter ++;
}

So in the scenario above you actually retireved only 
five records. If you were not to have that strange
where statement in your SQL, you would waste creation
of exactly 1995 records. But since you did have it 
you only wasted the retrieval of your ids and 
<page-size> - 5 records. JBoss lets you manage this 
situation thru that where and the settings in the 
jbosscmp-jdbc.xml

<read-ahead>
        <strategy>on-load</strategy>
      <page-size>1000</page-size>
      <eager-load-group>*</eager-load-group>
</read-ahead>

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Rafal
> Kedziorski
> Sent: Wednesday, February 26, 2003 6:57 AM
> To: [EMAIL PROTECTED]
> Subject: [JBoss-user] EntityBean findAll() method
> 
> 
> Hi,
> 
> my every entity beas has findAll() method defined in ejb-jar.xml 
> as follow:
> 
> <query>
>   <query-method>
>     <method-name>findAll</method-name>
>       <method-params/>
>   </query-method>
>   <ejb-ql><![CDATA[SELECT OBJECT(o) FROM firm o]]></ejb-ql>
> </query>
> 
> Could be this done better by other mechanism? JBoss are generating this 
> query for PostgreSQL:
> 
> // get all id's
> LOG:  query: SELECT t0_o.firm_id FROM firm t0_o
> 
> // call for every id
> LOG:  query:
> SELECT firm_id,name FROM firm WHERE (firm_id=1) OR (firm_id=2) OR 
> (firm_id=1046258766552575) OR (firm_id=1046258766812847) OR 
> (firm_id=1046258766781998) OR (firm_id=1046258766823725) OR (
> firm_id=1046258766815290) OR (firm_id=1046258766821931) OR 
> (firm_id=1046258766808355) OR (firm_id=1046258766805899) OR 
> (firm_id=1046258766840567) OR (firm_id=1046258766818653) OR 
> (firm_id=1046258766857549) OR (firm_id=1046258766870043)
> 
> ...
> 
> LOG:  query: SELECT firm_id,name FROM firm WHERE 
> (firm_id=1046258766821931) OR (firm_id=1046258766808355) OR 
> (firm_id=1046258766805899) OR (firm_id=1046258766840567) OR 
> (firm_id=1046258766818653) OR (
> firm_id=1046258766857549) OR (firm_id=1046258766870043)
> 
> ...
> 
> LOG:  query: SELECT firm_id,name FROM firm WHERE 
> (firm_id=1046258766818653) OR (firm_id=1046258766857549) OR 
> (firm_id=1046258766870043)
> 
> ...
> 
> LOG:  query: SELECT firm_id,name FROM firm WHERE 
> (firm_id=1046258766857549) OR (firm_id=1046258766870043)
> 
> ...
> 
> // last sql query
> LOG:  query: SELECT firm_id,name FROM firm WHERE 
> (firm_id=1046258766870043)
> 
> 
> why are sending JBoss not for every firm_id one query?
> 
> I have other tables, where are stored much more values. which generate 
> than longer query.
> 
> 
> Best Regards,
> Rafal
> 
> 
> 
> -------------------------------------------------------
> This SF.net email is sponsored by: Scholarships for Techies!
> Can't afford IT training? All 2003 ictp students receive scholarships.
> Get hands-on training in Microsoft, Cisco, Sun, Linux/UNIX, and more.
> www.ictp.com/training/sourceforge.asp
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-user
> 


-------------------------------------------------------
This SF.net email is sponsored by: Scholarships for Techies!
Can't afford IT training? All 2003 ictp students receive scholarships.
Get hands-on training in Microsoft, Cisco, Sun, Linux/UNIX, and more.
www.ictp.com/training/sourceforge.asp
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to