You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by Frédéric Esnault <fe...@legisway.com> on 2007/06/20 13:38:46 UTC

SQL request parse error

Hi all,

 

I encountered a problem working with a SQL request :

 

SELECT lgw:contractorType.lgw:title FROM lgw:contractorType, lgw:contractType 

WHERE lgw:contractType.jcr:uuid= 'b744b41b-8425-4008-99a6-ce8456d87c4e' 

AND lgw:contractorType.jcr:uuid=lgw:contractType.lgw:internalContractor

 

After debug, here is the analysis. The error is : javax.jcr.query.InvalidQueryException

But actually, the error is a NullPointerException.

 

The problem comes from the join.

During the AndExpression evaluation, it evaluates the two AndOperands. The first one is :

 

lgw:contractType.jcr:uuid= 'b744b41b-8425-4008-99a6-ce8456d87c4e'

 

and everything goes fine. The second one is :

 

lgw:contractorType.jcr:uuid=lgw:contractType.lgw:internalContractor

 

and there it fails because during the evaluation,it calls createRelationQueryNode in JCRSQLQueryBuilder and in the first case, no problem, but in the second case it fails because the first thing done in this method is : String stringValue = literal.getValue();

 

But in the second case, there is no literal value, it deals with an Identifier instead of a literal, but it seems to try and evaluate  it as a literal. And as it's not a literal, the ASTLiteral[] value element is not filled, so it's null. Then, value[0].getValue() raises the NullPointerException.

 

Is it a bug? Or is join not implemented? There is a getIdentifier (SimpleNode node) method in the anonymous DefaultParserVisitor class defined in the visit(ASTPredicate node, Object data) of JCRSQLQueryBuilder, but cannot step into it.

 

Frederic Esnault


RE: SQL request parse error

Posted by Frédéric Esnault <fe...@legisway.com>.
Ok thanks for the jcr:deref hint !
But nothing is planned for other kinds of joins?
For example, I have managers defined as contract nodes property, I will never be able to join the contractor manager property (a name as a string) on a contact node's name property? Or may be somehow with xpath?

And subsidiary question : I read here once that because of shared abstract query language, something done for xpath must be done for sql also. Isn't there a jcr:deref equivalent in sql?

Frédéric Esnault - Ingénieur R&D

-----Message d'origine-----
De : Jukka Zitting [mailto:jukka.zitting@gmail.com] 
Envoyé : mercredi 20 juin 2007 13:56
À : dev@jackrabbit.apache.org
Objet : Re: SQL request parse error

Hi,

On 6/20/07, Frédéric Esnault <fe...@legisway.com> wrote:
> Don't tell me it's because of spec, section 8.5.2.6 about joins, only on
> primary node type and mixin node type tables and on jcr:path property....
> Please !

Sorry...

However, in your case you may want to take a look at the jcr:deref()
mechanism available in XPath.

BR,

Jukka Zitting

Re: SQL request parse error

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On 6/20/07, Frédéric Esnault <fe...@legisway.com> wrote:
> Don't tell me it's because of spec, section 8.5.2.6 about joins, only on
> primary node type and mixin node type tables and on jcr:path property....
> Please !

Sorry...

However, in your case you may want to take a look at the jcr:deref()
mechanism available in XPath.

BR,

Jukka Zitting

RE: SQL request parse error

Posted by Frédéric Esnault <fe...@legisway.com>.
Don't tell me it's because of spec, section 8.5.2.6 about joins, only on primary node type and mixin node type tables and on jcr:path property....Please !

Frédéric Esnault - Ingénieur R&D

-----Message d'origine-----
De : Frédéric Esnault [mailto:fesn@legisway.com] 
Envoyé : mercredi 20 juin 2007 13:44
À : dev@jackrabbit.apache.org
Objet : RE: SQL request parse error

Just a correction, the NullPointerException is raised by : literal.getValue();

It seems the query is correctly parsed, it gets the identifiers, but seems to use the literal code (restriction) for identifier comparison (join).

Any idea ?

Frédéric Esnault - Ingénieur R&D


-----Message d'origine-----
De : Frédéric Esnault [mailto:fesn@legisway.com] 
Envoyé : mercredi 20 juin 2007 13:39
À : dev@jackrabbit.apache.org
Objet : SQL request parse error

Hi all,

 

I encountered a problem working with a SQL request :

 

SELECT lgw:contractorType.lgw:title FROM lgw:contractorType, lgw:contractType 

WHERE lgw:contractType.jcr:uuid= 'b744b41b-8425-4008-99a6-ce8456d87c4e' 

AND lgw:contractorType.jcr:uuid=lgw:contractType.lgw:internalContractor

 

After debug, here is the analysis. The error is : javax.jcr.query.InvalidQueryException

But actually, the error is a NullPointerException.

 

The problem comes from the join.

During the AndExpression evaluation, it evaluates the two AndOperands. The first one is :

 

lgw:contractType.jcr:uuid= 'b744b41b-8425-4008-99a6-ce8456d87c4e'

 

and everything goes fine. The second one is :

 

lgw:contractorType.jcr:uuid=lgw:contractType.lgw:internalContractor

 

and there it fails because during the evaluation,it calls createRelationQueryNode in JCRSQLQueryBuilder and in the first case, no problem, but in the second case it fails because the first thing done in this method is : String stringValue = literal.getValue();

 

But in the second case, there is no literal value, it deals with an Identifier instead of a literal, but it seems to try and evaluate  it as a literal. And as it's not a literal, the ASTLiteral[] value element is not filled, so it's null. Then, value[0].getValue() raises the NullPointerException.

 

Is it a bug? Or is join not implemented? There is a getIdentifier (SimpleNode node) method in the anonymous DefaultParserVisitor class defined in the visit(ASTPredicate node, Object data) of JCRSQLQueryBuilder, but cannot step into it.

 

Frederic Esnault


RE: SQL request parse error

Posted by Frédéric Esnault <fe...@legisway.com>.
Just a correction, the NullPointerException is raised by : literal.getValue();

It seems the query is correctly parsed, it gets the identifiers, but seems to use the literal code (restriction) for identifier comparison (join).

Any idea ?

Frédéric Esnault - Ingénieur R&D


-----Message d'origine-----
De : Frédéric Esnault [mailto:fesn@legisway.com] 
Envoyé : mercredi 20 juin 2007 13:39
À : dev@jackrabbit.apache.org
Objet : SQL request parse error

Hi all,

 

I encountered a problem working with a SQL request :

 

SELECT lgw:contractorType.lgw:title FROM lgw:contractorType, lgw:contractType 

WHERE lgw:contractType.jcr:uuid= 'b744b41b-8425-4008-99a6-ce8456d87c4e' 

AND lgw:contractorType.jcr:uuid=lgw:contractType.lgw:internalContractor

 

After debug, here is the analysis. The error is : javax.jcr.query.InvalidQueryException

But actually, the error is a NullPointerException.

 

The problem comes from the join.

During the AndExpression evaluation, it evaluates the two AndOperands. The first one is :

 

lgw:contractType.jcr:uuid= 'b744b41b-8425-4008-99a6-ce8456d87c4e'

 

and everything goes fine. The second one is :

 

lgw:contractorType.jcr:uuid=lgw:contractType.lgw:internalContractor

 

and there it fails because during the evaluation,it calls createRelationQueryNode in JCRSQLQueryBuilder and in the first case, no problem, but in the second case it fails because the first thing done in this method is : String stringValue = literal.getValue();

 

But in the second case, there is no literal value, it deals with an Identifier instead of a literal, but it seems to try and evaluate  it as a literal. And as it's not a literal, the ASTLiteral[] value element is not filled, so it's null. Then, value[0].getValue() raises the NullPointerException.

 

Is it a bug? Or is join not implemented? There is a getIdentifier (SimpleNode node) method in the anonymous DefaultParserVisitor class defined in the visit(ASTPredicate node, Object data) of JCRSQLQueryBuilder, but cannot step into it.

 

Frederic Esnault