What do you'll think of writing a stateful session bean to hold these data
and make it gets the data from database once/twice a day?

On Sun, Feb 24, 2008 at 9:20 AM, Jeromy Evans <
[EMAIL PROTECTED]> wrote:

> Cheng Wei Lee wrote:
> > Hi all,
> >
> > In most web applications, it is unavoidable to have some codes/lookup
> > tables, for example, in a form we may need to display the country list.
> If
> > we were to hit the database per request to get this list for displaying
> in
> > the dropdown, it would be too expensive. If we load these values during
> the
> > filter init(), it cannot be refreshed. What would be the best approach
> to
> > handle such scenario?
> >
> > Thanks!
> >
> I think the answer is "it depends".  There are some principles that
> apply though:
>  - avoid it. If the data changes so infrequently that you're likely to
> restart the app anyway, don't waste effort handling the data as if it's
> something it's not.   If it's not critical that users see data that's
> accurate to the moment, don't try to achieve that.  Put the effort in
> where it's really needed.
>  - abstract it.  Whatever the mechanism you use to cache and refresh the
> data, ensure that's hidden behind a façade rather than spread though the
> code that's using it.
>  - cache at an appropriate layer.  For example, when using hibernate I'd
> simply execute the query every time but ensure the object is in the
> Level 2 cache and that the query is cached.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to