[Ambra-dev] Filtering by Annotation Type
Life is hard, and then you die
ronald at innovation.ch
Fri Nov 7 17:27:35 PST 2008
On Fri, Nov 07, 2008 at 02:03:05PM -0800, Pradeep Krishnan wrote:
>
> Bill Oconnor wrote:
>
> > Just to make sure I have this straight:
> >
> > 'select a from ArticleAnnotation a where...' is going to return all
> > objects that are Annotations
>
> No. It returns only objects that are ArticleAnnotations which is a
> subset of Annotations.
>
> and 'select a from FormalCorrection...'
> > returns FormalCorrection's etc - correct?
> >
>
> Yes, this returns only objects that are FormalCorrections.
>
> > Therefore the 'a.<rdf:type> = :type' approach is the only way to filter
> > a list of multiple types like for example asking for major and minor
> > corrections only.
>
> If all you are interested in is corrections, then 'select a from
> Correction ...' will do. But suppose you wanted to get FormalCorrections
> and Ratings (something that doesn't share a common super-class or you
> only want a subset of the sub-classes of the common super-class), you
> could add query constraints to constrain the type. But in general there
> isn't usually a requirement to do something like that. If there is, a
> third option is to define a marker interface (eg. GreenAnnotations) and
> add an 'implements GreenAnnotations' to the ones you want to mark as
> GreenAnnotations. Then again your query becomes as simple as 'select a
> from GreenAnnotations a ...'.
Just an additional note: there is a subtle difference between the
filtering of, say, FormalCorrection's and those of GreenAnnotation's
in the above example: because FormalCorrection's have their own rdf
type the filtering will be part of the resulting tql query, i.e. will
be done on the server, whereas the filtering of GreenAnnotation's will
occur inside OTM. This means that the OQL query may be returning null
for get() on some of the rows.
As an aside, Criteria.list will filter out the nulls so from an app
perspective there is no difference where the filtering occurs. We may
be able to do something in OQL where if the whole row would have only
nulls then we skip the row internally,
Cheers,
Ronald
More information about the Ambra-dev
mailing list