You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Brian Thompson <BT...@sewardinc.com> on 2007/01/29 21:19:02 UTC

SQL Queries in Jackrabbit

Hey everyone,
 
I have a node structure modeling a hierarchy of
 
Types-Modules-Sections-Pages
 
I'm trying to set up queries to grab all the pages in a given Type, all
pages in a given Module, etc.  What I'd really like to do is get a list
of Page nodes via a SQL (or XPath, but I'm more familiar with SQL)
query, but I can't figure out how to specify that a query should examine
a property of a parent node.
 
If this were a regular RDBMS, I'd do
 
SELECT * 
FROM module
INNER JOIN type ON type.ID = module.typeID
WHERE type.name = 'foo'
 
but I can't find any documentation for Jackrabbit that explains how to
reference a parent node in a query.
 
Thanks,
 
Brian

Re: SQL Queries in Jackrabbit

Posted by David Johnson <db...@gmail.com>.
Joins are a lot more limited in a Jackrabbit/JSR-170 repository, so the SQL
that you might want to work may not be supported by the standard.  If I
remember correctly, the standard only requires one type of join to work.
>From the spec (
http://jcp.org/aboutJava/communityprocess/maintenance/jsr170/index.html):

"Support for joins is required only on the jcr:path column
and only for joining a primary node type table with a mixin
node type tables. For example:
SELECT nt:file.jcr:path, jcr:lockOwner
FROM nt:file, mix:lockable
WHERE jcr:lockOwner = 'John'
        AND mynt:file.jcr:path=mix:lockable.jcr:path
Additional join support, on other columns and with other
tables, is optional."

-Dave


On 1/29/07, Brian Thompson <BT...@sewardinc.com> wrote:
>
> Hey everyone,
>
> I have a node structure modeling a hierarchy of
>
> Types-Modules-Sections-Pages
>
> I'm trying to set up queries to grab all the pages in a given Type, all
> pages in a given Module, etc.  What I'd really like to do is get a list
> of Page nodes via a SQL (or XPath, but I'm more familiar with SQL)
> query, but I can't figure out how to specify that a query should examine
> a property of a parent node.
>
> If this were a regular RDBMS, I'd do
>
> SELECT *
> FROM module
> INNER JOIN type ON type.ID = module.typeID
> WHERE type.name = 'foo'
>
> but I can't find any documentation for Jackrabbit that explains how to
> reference a parent node in a query.
>
> Thanks,
>
> Brian
>