Hi..
 I also have almost the same problem... See I have a few tables..
I have a class for each table.. now i want to have functions in each class
for searching etc.. smthng like person.findByPrimaryKey("fasihuce");
so wat i did was i made a base class DataObject which has all these
functions.. it works fine for create, remove etc.. 
smthng like...
> > class DataObject
> > DataObject findByPrimaryKey(Object primaryKey) {
> >  this.load(Object primaryKey);
> > }

however to implement a search on all the fields i cannot do something
like this...
> SELECT o FROM dot.com.User o where firstName like $1 or lastName like $1
> order by lastName, firstName
as in the base class i dont know the fields in the derived class...

one way is to obviously implement the function as an abstract function and
implement the query in the derived class.. but is there any other
alternative???

bye
Fasih

On Sun, 11 Jan 2004, Stein M. Hugubakken wrote:

> Abhishek Paul wrote:
> > Hi..
> > I have implemented a base class DataObject which encapsulates all the
> > functions required.. this serves as the base class for each of the class
> > representing a table in the database.. like findByPrimaryKey, delete..etc
> > However I want a search function in this base class which can find the
> > occurence of a string in any of the field in the dataobject.. 
> > for eg...
> > 
> > class DataObject 
> > DataObject findByPrimaryKey(Object primaryKey) {
> >  this.load();
> > }
> > etc...
> > 
> > 
> > Person extends DataObject..
> > Person p;
> > p.findByPrimaryKey("fasihuce"); // Get the details in p
> > Vector ppl = p.search("fasih"); // Get the vector of all the Persons where
> >    // the string "fasih"  appears in any of the column.. and this is
> >    // implemented in the base class like findByPrimaryKey
> > 
> > 
> > I could not figure out a way to find out how to query multiple fields
> > in the base class...
> > 
> 
> I'm not sure if this is what you want, but I'm using a plain oql-query 
> for *searching*:
> SELECT o FROM dot.com.User o where firstName like $1 or lastName like $1 
> order by lastName, firstName
> 
> Stein
> 
> ----------------------------------------------------------- 
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-dev
> 

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to