You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by jr...@aep.com on 2003/07/28 13:30:15 UTC

[repost] Best way to globally filter objects during fetch. RowReader or CacheFilter?

Thomas/Armin,

What is the best way to filter instances of a class every time that it's
fetched by OJB?  Here is my situation...


I have a class called 'Owner' which has an attribute 'ownershipPercent'.  I
want any queries run by OJB against this class to ALWAYS filter out
records/objects whose ownershipPercent == 0.0.  Of course, the obvious way
to do this is to add this condition to my Criteria everywhere in my code
that I fetch 'Owners'.  Although, I can do this, it's not really practical
when I consider the amount of time it's going to take me and when I
consider the regression impacts.  I have been considering the use of one of
the following:

1) Using a custom RowReader on the 'Owner' class descriptor to filter out
the unwanted rows/objects
2) Using a CacheFilter to filter out 'Owners' where the ownershipPercent is
0.

Either solution seems like it *might* suit my need as it will handle any
fetches on these objects gotten via collection descriptors, reference
descriptors, or just queries against the 'Owner' class itself.

Am I on the right track at all??  If so, which of these solutions is
better?  I have looked into the use of the RowReader and was wondering how
to fit this functionality into the readObjectArrayFrom method and I wasn't
sure if it was wise to simply skip rows in the ResultSet or not.

Thanks in advance,
Jason





---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: [repost] Best way to globally filter objects during fetch. RowReader or CacheFilter?

Posted by Armin Waibel <ar...@code-au-lait.de>.
Hi Jason,

> 2) Using a CacheFilter to filter out 'Owners' where the
ownershipPercent is
> 0.
This is definitely the wrong way to fulfill your condition.

>
> 1) Using a custom RowReader on the 'Owner' class descriptor to filter
out
> the unwanted rows/objects

Implement a custom RowReader seems a good way
for filtering objects. You can find an similar example
in docu
http://db.apache.org/ojb/tutorial3.html#rowreader example

regards,
Armin

----- Original Message -----
From: <jr...@aep.com>
To: <oj...@db.apache.org>
Sent: Monday, July 28, 2003 1:30 PM
Subject: [repost] Best way to globally filter objects during fetch.
RowReader or CacheFilter?


> Thomas/Armin,
>
> What is the best way to filter instances of a class every time that
it's
> fetched by OJB?  Here is my situation...
>
>
> I have a class called 'Owner' which has an attribute
'ownershipPercent'.  I
> want any queries run by OJB against this class to ALWAYS filter out
> records/objects whose ownershipPercent == 0.0.  Of course, the obvious
way
> to do this is to add this condition to my Criteria everywhere in my
code
> that I fetch 'Owners'.  Although, I can do this, it's not really
practical
> when I consider the amount of time it's going to take me and when I
> consider the regression impacts.  I have been considering the use of
one of
> the following:
>
> 1) Using a custom RowReader on the 'Owner' class descriptor to filter
out
> the unwanted rows/objects
> 2) Using a CacheFilter to filter out 'Owners' where the
ownershipPercent is
> 0.
>
> Either solution seems like it *might* suit my need as it will handle
any
> fetches on these objects gotten via collection descriptors, reference
> descriptors, or just queries against the 'Owner' class itself.
>
> Am I on the right track at all??  If so, which of these solutions is
> better?  I have looked into the use of the RowReader and was wondering
how
> to fit this functionality into the readObjectArrayFrom method and I
wasn't
> sure if it was wise to simply skip rows in the ResultSet or not.
>
> Thanks in advance,
> Jason
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org