Hi,
I fail to get a good understandinding of XWiki Query Language (my goal is
to transform working HQL to XWQL)
This code is working…
{{velocity}}
#set($classname = "CdLSATEPublic.CdLSATEPublicClass")
#set($findWQL = "
from doc.object($classname) as qat
")
#set($resultDocuments = $services.query.xwql($findWQL).execute())
#foreach($resultDocument in $resultDocuments)
$resultDocument
#end
{{/velocity}}
While this code is not working..
{{velocity}}
#set($classname = "CdLSATEPublic.CdLSATEPublicClass")
#set($findWQL = "
from doc.object($classname) as qat
where qat.language = 'en'
")
#set($resultDocuments = $services.query.xwql($findWQL).execute())
#foreach($resultDocument in $resultDocuments)
$resultDocument
#end
{{/velocity}}
Where is my problem? (see error code below…)
Caused by: org.xwiki.velocity.XWikiVelocityException: Failed to
evaluate content with id [xwiki:CdlsatdCode.try2]
at
org.xwiki.velocity.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:247)
at
org.xwiki.velocity.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:184)
at
org.xwiki.rendering.internal.macro.velocity.VelocityMacro.evaluateString(VelocityMacro.java:124)
... 106 more
Caused by: org.apache.velocity.exception.MethodInvocationException:
Invocation of method 'execute' in class
org.xwiki.query.internal.DefaultQuery threw exception
org.xwiki.query.QueryException: Exception while translating [
from doc.object(CdLSATEPublic.CdLSATEPublicClass) as qat
where qat.language = 'en'
] XWQL query to the [hql] language. Query statement = [
from doc.object(CdLSATEPublic.CdLSATEPublicClass) as qat
where qat.language = 'en'
] at xwiki:CdlsatdCode.try2[line 7, column 57]
at
org.apache.velocity.runtime.parser.node.ASTMethod.handleInvocationException(ASTMethod.java:243)
at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:187)
at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:280)
at org.apache.velocity.runtime.parser.node.ASTReference.value(ASTReference.java:567)
at org.apache.velocity.runtime.parser.node.ASTExpression.value(ASTExpression.java:71)
at
org.apache.velocity.runtime.parser.node.ASTSetDirective.render(ASTSetDirective.java:142)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:342)
at
org.xwiki.velocity.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:228)
... 108 more
Caused by: org.xwiki.query.QueryException: Exception while translating [
from doc.object(CdLSATEPublic.CdLSATEPublicClass) as qat
where qat.language = 'en'
] XWQL query to the [hql] language. Query statement = [
from doc.object(CdLSATEPublic.CdLSATEPublicClass) as qat
where qat.language = 'en'
]
at org.xwiki.query.xwql.internal.XWQLQueryExecutor.execute(XWQLQueryExecutor.java:76)
at
org.xwiki.query.internal.DefaultQueryExecutorManager.execute(DefaultQueryExecutorManager.java:72)
at
org.xwiki.query.internal.SecureQueryExecutorManager.execute(SecureQueryExecutorManager.java:80)
at org.xwiki.query.internal.DefaultQuery.execute(DefaultQuery.java:236)
at sun.reflect.GeneratedMethodAccessor413.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.doInvoke(UberspectImpl.java:395)
at
org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:384)
at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:173)
... 114 more
Caused by: org.xwiki.query.jpql.lexer.LexerException: [1,95] Unknown token:
at org.xwiki.query.jpql.lexer.Lexer.getToken(Lexer.java:809)
at org.xwiki.query.jpql.lexer.Lexer.peek(Lexer.java:36)
at org.xwiki.query.jpql.parser.Parser.parse(Parser.java:110)
at org.xwiki.query.jpql.internal.JPQLParser.parse(JPQLParser.java:46)
at
org.xwiki.query.xwql.internal.hql.XWQLtoHQLTranslator.translate(XWQLtoHQLTranslator.java:55)
at org.xwiki.query.xwql.internal.XWQLQueryExecutor.execute(XWQLQueryExecutor.java:59)
... 123 more
Gerritjan