E
epicwinter
I am working on optimizing loading of objects. Here is my problem I
use a base class DataAccessObject.
public class DataAccessObject
{
/**
* gets instance of DataAccessObject represented by the id and loads
the data
*
**/
public DataAccessObject(int id)
{
//load data here
}
}
So to get the shape object from the db specified by the 2 id:
Shape aShape = new Shape(2);
Now for some of my DataAccessObject sub clases I would like to store a
cache that will be loaded the first time it is called. So I want to
override this constructor to instead grab the data from the cache like
so:
public Cached_DataAccessObject(int id)
{
this = cache.get(new Integer(id));//the cache is a map
}
But you can't do that cause the "this" key word is not intended to be
referenced in this manner. Does anyone know of a way to make this
work? Or a better alternative?
thanks
use a base class DataAccessObject.
public class DataAccessObject
{
/**
* gets instance of DataAccessObject represented by the id and loads
the data
*
**/
public DataAccessObject(int id)
{
//load data here
}
}
So to get the shape object from the db specified by the 2 id:
Shape aShape = new Shape(2);
Now for some of my DataAccessObject sub clases I would like to store a
cache that will be loaded the first time it is called. So I want to
override this constructor to instead grab the data from the cache like
so:
public Cached_DataAccessObject(int id)
{
this = cache.get(new Integer(id));//the cache is a map
}
But you can't do that cause the "this" key word is not intended to be
referenced in this manner. Does anyone know of a way to make this
work? Or a better alternative?
thanks