jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Zhenhua Guo <jen...@gmail.com>
Subject Question about query support in Jackrabbit 2.0
Date Thu, 17 Dec 2009 23:22:23 GMT
I read JCR2.0 spec and two query languages are supported: SQL2 and QOM.
I am using jcr2spi + spi2jcr. It looks weird considering that I can
directly use jackrabbit core. The reason is it's easy for future
extension. We can easily replace spi2jcr with spi2dav, spi2davex, etc
without modifying out code.
I constructed a query using QOM. It compiled OK, but when I ran it,
following error appeared
--------------------------
javax.jcr.query.InvalidQueryException: Query:
SELECT gadget1.* FROM [gr:textblob] AS tagtb INNER JOIN [gr:gadgettag]
AS tag INNER(*)JOIN [gr:gadgettags] AS tags INNER JOIN
[gr:gadgetinrepo] AS gadget1 ON ISCHILDNODE(tags, gadget1) ON
ISCHILDNODE(tag, tags) ON ISCHILDNODE(tagtb, tag) INNER JOIN
[gr:textblob] AS catkindtb INNER JOIN [gr:categorykind] AS
categorykind INNER JOIN [gr:gadgetcategory] AS category INNER JOIN
[gr:gadgetcategories] AS categories INNER JOIN [gr:gadgetinrepo] AS
gadget2 ON ISCHILDNODE(categories, gadget2) ON ISCHILDNODE(category,
categories) ON ISCHILDNODE(categorykind, category) ON
ISCHILDNODE(catkindtb, categorykind) ON ISSAMENODE(gadget1, gadget2,
[.]); expected: ON
	org.apache.jackrabbit.commons.query.sql2.Parser.getSyntaxError(Parser.java:968)
	org.apache.jackrabbit.commons.query.sql2.Parser.read(Parser.java:641)
	org.apache.jackrabbit.commons.query.sql2.Parser.parseSource(Parser.java:186)
	org.apache.jackrabbit.commons.query.sql2.Parser.createQueryObjectModel(Parser.java:112)
	org.apache.jackrabbit.commons.query.sql2.SQL2QOMBuilder.createQueryObjectModel(SQL2QOMBuilder.java:55)
	org.apache.jackrabbit.core.query.QOMQueryFactory.createQuery(QOMQueryFactory.java:69)
	org.apache.jackrabbit.core.query.CompoundQueryFactory.createQuery(CompoundQueryFactory.java:67)
	org.apache.jackrabbit.core.query.QueryManagerImpl.createQuery(QueryManagerImpl.java:98)
	org.apache.jackrabbit.spi2jcr.RepositoryServiceImpl.createQuery(RepositoryServiceImpl.java:1762)
	org.apache.jackrabbit.spi2jcr.RepositoryServiceImpl.checkQueryStatement(RepositoryServiceImpl.java:1063)
	org.apache.jackrabbit.jcr2spi.WorkspaceManager.checkQueryStatement(WorkspaceManager.java:320)
	org.apache.jackrabbit.jcr2spi.query.QueryImpl.<init>(QueryImpl.java:140)
	org.apache.jackrabbit.jcr2spi.query.QueryObjectModelImpl.<init>(QueryObjectModelImpl.java:62)
	org.apache.jackrabbit.jcr2spi.query.QueryManagerImpl$QOMFactory.createQuery(QueryManagerImpl.java:167)
	org.apache.jackrabbit.spi.commons.query.qom.QueryObjectModelFactoryImpl.createQuery(QueryObjectModelFactoryImpl.java:173)
--------------------------

I formatted the generated sql2 statement in a readable way:
--------------------------
SELECT gadget1.*
FROM
        [gr:textblob] AS tagtb INNER JOIN
            [gr:gadgettag] AS tag INNER JOIN
                [gr:gadgettags] AS tags INNER JOIN
                [gr:gadgetinrepo] AS gadget1
                ON ISCHILDNODE(tags, gadget1)
            ON ISCHILDNODE(tag, tags)
        ON ISCHILDNODE(tagtb, tag)

    INNER JOIN

        [gr:textblob] AS catkindtb INNER JOIN
            [gr:categorykind] AS categorykind INNER JOIN
                [gr:gadgetcategory] AS category INNER JOIN
                    [gr:gadgetcategories] AS categories INNER JOIN
                    [gr:gadgetinrepo] AS gadget2
                    ON ISCHILDNODE(categories, gadget2)
                ON ISCHILDNODE(category, categories)
            ON ISCHILDNODE(categorykind, category)
        ON ISCHILDNODE(catkindtb, categorykind)
    ON ISSAMENODE(gadget1, gadget2, [.]);
--------------------------

The query includes netsted joins (A operand of a join is another
join). Maybe that is not supported by spi2jcr now?

Thanks
Gerald

Mime
View raw message