Civici – thanks for the information,
this is helpful.
I have questions about the methods to read
the DB:
trackList = getDBHelper().readTrackListFromDB();
–
are these
methods in your request-scope backing bean? or are they methods in
another object – if so, is it a managed-request-scope bean?
thanks.
From: Cagatay Civici
[mailto:[EMAIL PROTECTED]
Sent: Sunday, January 08, 2006
5:40 AM
To: MyFaces
Discussion; [EMAIL PROTECTED]
Subject: Re: Newbie questions -
database calls and caching data
Hi,
The practice I am using for a long time to minimize the db access is storing
the data from db in a member variable, this was the one Simon already
suggested. Getters that are bind to the components are called a couple of
times, if you are not careful enough than performance issues will likely to
occur. You should cache the db data in request scope like this;
public class AlbumView {
...
private List _trackList;
...
public List getTrackList()
{
if(_trackList == null)
trackList = getDBHelper().readTrackListFromDB();
return trackList;
}
The first access to the list will read the data from db, later accesses will
not hit the db and return the data that is cached. As a good practice maybe you
might have a dbhelper class that reads the tracklist and does other db related
stuff, this will enable you to use the same mechanism easily in other pages
without recoding the sql stuff.