You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "G.L. Grobe" <ga...@grobe.net> on 2002/07/23 03:02:19 UTC

is this correct behaviour everytime a method is ref'd

I'm trying to make things more efficient in my app and this is one that
really gets me. The following velocity code ...

   #foreach ( $key in $productList.keySet() )
      <option value="$productList.get($key)">$productList.get($key)
   #end

... calls a servlet which does a lookup to a session bean which queries a
database and populates a Map w/ values from the query and pass them back to
the template.

The problem is that there are database queries that are almost proportional
to the number of times that I reference $productList in the above code. So
as it's in there 3 times, I'll see 3 dbase queries.

Is this behavior correct or would anyone know the reason for it?

Any help much appreciated


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: is this correct behaviour everytime a method is ref'd

Posted by "Geir Magnusson Jr." <ge...@adeptra.com>.
On 7/22/02 9:02 PM, "G.L. Grobe" <ga...@grobe.net> wrote:

> I'm trying to make things more efficient in my app and this is one that
> really gets me. The following velocity code ...
> 
>  #foreach ( $key in $productList.keySet() )
>     <option value="$productList.get($key)">$productList.get($key)
>  #end
> 
> ... calls a servlet which does a lookup to a session bean which queries a
> database and populates a Map w/ values from the query and pass them back to
> the template.
> 
> The problem is that there are database queries that are almost proportional
> to the number of times that I reference $productList in the above code. So
> as it's in there 3 times, I'll see 3 dbase queries.
> 

If productList is a Map, why is there any more that 1 db query?
$productList.get() should just be accessing the get() method on the Map
class.


> Is this behavior correct or would anyone know the reason for it?
> 
> Any help much appreciated
> 
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 

-- 
Geir Magnusson Jr. 
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>