You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by Felix Meschberger <fm...@gmail.com> on 2007/08/31 15:13:16 UTC

[OCM] Add simple query API

Hi all,

In our day-to-day use of JCR and the OCM, we discovered, that often
times we have a simple requirement to shoot a query at the repository
and just get the nodes returned. This contrasts the full-blown query
support available through the JCR QueryManager. Likewise, the OCM has
its own QueryManager with its Filter interface and mechanism. Here, too,
often times, it seems easier to just shoot a known query and get the
objects back that to build a filter to execute.

For this reason, Betrand and I propose the following addition to the
ObjectContentManager interface:

     Iterator getObjects(String queryExpression, String language) throws
            OCMInvalidSyntaxException, ObjectContentMappingException;

     OCMInvalidSyntaxException extends ObjectContentMappingException
            wrapping the JCR InvalidSyntaxException

The intent is to get an Iterator of objects mapped from the nodes
returned by the queryExpression given in the query language. The
queryExpression and language are used to create the JCR Query from whose
result the mapped objects are retrieved.

We know, that this is just kind of a utility function but nonetheless a
often used one.

What do you think of this addition ? If there is enough interest - at
least we are interested as well as some Sling-based applications might
be - we have a patch handy to implement this.

Any feedback is welcome.

Regards
Felix



Re: [OCM] Add simple query API

Posted by Bertrand Delacretaz <bd...@apache.org>.
On 8/31/07, Christophe Lombart <ch...@gmail.com> wrote:
> ...I thought also about a query language like OQL oriented for content repo
> but it will take more time to implement. Futhermore, I'm not yet sure that
> will be a great help....

Agreed - having used both OJB and Hibernate, I often feel that the
special query languages required by "something-to-object" mappers get
in the way when one knows the native query language.

Allowing people to use the JCR query languages that they know (and
love?), and getting the results as OCM-mapped objects sounds like a
very pragmatic solution.

-Bertrand

Re: [OCM] Add simple query API

Posted by Felix Meschberger <fm...@gmail.com>.
Hi,

Am Freitag, den 31.08.2007, 11:55 -0700 schrieb Padraic I. Hannon:
> I concur, and think an OQL type query language would be nice as well. I 
> guess XPATH can get you most of the way there, however, I have not yet 
> been able to get my eyes to read XPATH correctly as they have spent too 
> much time looking at SQL...

Well, JSR-283 seems to switch the primary query langugage for
repositories from XPath to SQL-like, so lately I started using JCR SQL
rather than XPath... But this is another story :-)

So, I will create the issue and the patch.

Regards
Felix

> 
> -paddy
> 
> Christophe Lombart wrote:
> > +1
> >
> > I think more and more use cases will need something like this.
> > I thought also about a query language like OQL oriented for content repo
> > but it will take more time to implement. Futhermore, I'm not yet sure that
> > will be a great help. So, let's start with your proposal.
> >
> >
> > br,
> > Christophe
> >   


Re: [OCM] Add simple query API

Posted by "Padraic I. Hannon" <pi...@wasabicowboy.com>.
I concur, and think an OQL type query language would be nice as well. I 
guess XPATH can get you most of the way there, however, I have not yet 
been able to get my eyes to read XPATH correctly as they have spent too 
much time looking at SQL...

-paddy

Christophe Lombart wrote:
> +1
>
> I think more and more use cases will need something like this.
> I thought also about a query language like OQL oriented for content repo
> but it will take more time to implement. Futhermore, I'm not yet sure that
> will be a great help. So, let's start with your proposal.
>
>
> br,
> Christophe
>   

Re: [OCM] Add simple query API

Posted by Christophe Lombart <ch...@gmail.com>.
+1

I think more and more use cases will need something like this.
I thought also about a query language like OQL oriented for content repo
but it will take more time to implement. Futhermore, I'm not yet sure that
will be a great help. So, let's start with your proposal.


br,
Christophe

On 8/31/07, Felix Meschberger <fm...@gmail.com> wrote:
>
> Hi all,
>
> In our day-to-day use of JCR and the OCM, we discovered, that often
> times we have a simple requirement to shoot a query at the repository
> and just get the nodes returned. This contrasts the full-blown query
> support available through the JCR QueryManager. Likewise, the OCM has
> its own QueryManager with its Filter interface and mechanism. Here, too,
> often times, it seems easier to just shoot a known query and get the
> objects back that to build a filter to execute.
>
> For this reason, Betrand and I propose the following addition to the
> ObjectContentManager interface:
>
>      Iterator getObjects(String queryExpression, String language) throws
>             OCMInvalidSyntaxException, ObjectContentMappingException;
>
>      OCMInvalidSyntaxException extends ObjectContentMappingException
>             wrapping the JCR InvalidSyntaxException
>
> The intent is to get an Iterator of objects mapped from the nodes
> returned by the queryExpression given in the query language. The
> queryExpression and language are used to create the JCR Query from whose
> result the mapped objects are retrieved.
>
> We know, that this is just kind of a utility function but nonetheless a
> often used one.
>
> What do you think of this addition ? If there is enough interest - at
> least we are interested as well as some Sling-based applications might
> be - we have a patch handy to implement this.
>
> Any feedback is welcome.
>
> Regards
> Felix
>
>
>