Rickard,

May you tell me how to synchronize the static hashtable of a bean?  Is
synchronization allowed in beans?

Thanks.

Ruoqi Chen
Stockwalk.com Group Inc.

>-----Original Message-----
>From: Rickard =D6berg [mailto:[EMAIL PROTECTED]]
>Sent: Wednesday, November 29, 2000 3:48 AM
>To: [EMAIL PROTECTED]
>Subject: Re: 2 Basic questions about EJB
>=20
>=20
>On Wed, 29 Nov 2000 09:47:28 +0100, Francesco Marchioni
><[EMAIL PROTECTED]> wrote:
> >1) Is it a bad idea to put plain SQL queries in Session Beans ?
> >
> >I need somewhere in my code to make generic Sql queries to fill up
> >some combos with values- since every combo has its own query
> >I provided a config file in XML with the single query for=20
>every combo.
> >
> >Then I just wrote a method in my Session bean a method like this:
> >
> >Collection readSQL (String sql, params) {
> >
> >... execute query with params
> >
> >....fill up Collection with Resultset
> >
> >...return Collection
> >}
> >
> >is it a clean solution- technically speaking? or do I need to
> >contact Entity Beans and use their find methods ?
>=20
>Seems like a good idea to me.
>=20
>One additional thing you may want to do is if the data is=20
>fairly static
>then cache the results in the session bean. I.e. keep a hashtable =
with
>sql as key and result collection as value. If the sql string is in =
the
>hashtable, then return the collection. If not then query the=20
>db and put
>the result in the hashtable. If the data is semi-static you could =
also
>use a timeout to refresh from the db. This will make your system much
>speedier and you will put less strain on the db. If you use a static
>hashtable make sure you use synchronized properly when updating the
>hashtable.
>=20
>/Rickard
>=20
>--
>Rickard =D6berg
>=20
>Email: [EMAIL PROTECTED]
>=20
>=

_____________________________________________________________________________________
Get more from the Web.  FREE MSN Explorer download : http://explorer.msn.com

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to