Wiki source code of Query Language Specification
Last modified by Vincent Massol on 2024/11/19 16:12
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | == Query Language Specification == | ||
| 2 | |||
| 3 | XWQL is JPQL superset. See [[JPQL specification>>http://java.sun.com/javaee/5/docs/tutorial/doc/bnbuf.html]]. | ||
| 4 | |||
| 5 | {{velocity filter="none"}} | ||
| 6 | {{html clean="false" wiki="true"}} | ||
| 7 | <p> | ||
| 8 | XWiki-specific extensions in XWQL: | ||
| 9 | * short form queries: | ||
| 10 | ** "where <expr>" means "select doc.fullName where <expr>" | ||
| 11 | ** "from <fromlist> [where <expr>]" means "select doc.fullName from Document as doc, <fromlist> [where <expr>]" | ||
| 12 | * special syntax for XWiki objects in "from" and "where" clauses: | ||
| 13 | ** "from doc.object(Class) as obj" | ||
| 14 | ** "where doc.object(Class).prop = 'something'" | ||
| 15 | <p/> | ||
| 16 | |||
| 17 | <table> <tr> <td> Query </td> <td> XWQL (chosen method) </td> <td> HQL (Current method) </td> <td> XPath (Current QueryPlugin method, with unimplemented child axis support) </td> <td> Method 1 </td> <td> Method 2 </td> <td> Method 3 </td> <td> Method 4 </td> </tr> <tr> <td> Query listing all documents </td> <td> empty query </td> <td> empty query </td> <td> /*/* </td> <td> empty query </td> <td> empty query </td> <td> empty query </td> <td> empty query </td> </tr> <tr> <td> Query listing all documents create after a date </td> <td> where doc.creationDate > '2008-01-01' </td> <td> where [doc.]creationDate > '2008-01-01' </td> <td> /*/*[@creationDate > '2008-01-01'] </td> <td> where [doc.]creationDate > '2008-01-01' </td> <td> where [doc.]creationDate > '2008-01-01' </td> <td> where [doc.]creationDate > '2008-01-01' </td> <td> where [doc.]creationDate > '2008-01-01' </td> </tr> <tr> <td> Query listing all documents last updated by a user </td> <td> where doc.author = 'XWiki.LudovicDubost' </td> <td> where [doc.]author = 'XWiki.LudovicDubost' </td> <td> /*/*[@author = 'XWiki.LudovicDubost'] </td> <td> where [doc.]author = 'XWiki.LudovicDubost' </td> <td> where [doc.]author = 'XWiki.LudovicDubost' </td> <td> where [doc.]author = 'XWiki.LudovicDubost' </td> <td> where [doc.]author = 'XWiki.LudovicDubost' </td> </tr> <tr> <td> Query listing all documents with a class </td> <td> from doc.object(XWiki.XWikiUsers) as user </td> <td> , BaseObject as obj where doc.fullName = obj.name and obj.className = 'XWiki.XWikiUsers' </td> <td> /*/*[obj/XWiki/XWikiUsers] </td> <td> from XWiki.XWikiUsers </td> <td> where [doc.]XWiki.XWikiUsers </td> <td> where [doc.]class = 'XWiki.XWikiUsers' </td> <td> , XWiki.XWikiUsers as user where [doc.]id = user.docId </td> </tr> <tr> <td> Query on document with a class with a filter </td> <td> where doc.author = 'XWiki.LudovicDubost' and doc.object(XWiki.XWikiUsers).email like '%xwiki.com' </td> <td> , BaseObject as obj, StringProperty as prop where doc.fullName = obj.name and obj.className = 'XWiki.XWikiUsers' and obj.id=prop.id.id and prop.id.name='email' and prop.value like '%xwiki.com' and [doc.]author ='XWiki.LudovicDubost' </td> <td> /*/*[@author='XWiki.LudovicDubost' and obj/XWiki/XWikiUsers/@xp:email like '%xwiki.com'] </td> <td> from XWiki.XWikiUsers as user where user.email like '%xwiki.com' and [doc.]author='XWiki.LudovicDubost' </td> <td> where [[doc.]XWiki.XWikiUsers and] [doc.]XWiki.XWikiUsers.email like '%xwiki.com' and [doc.]author = 'XWiki.LudovicDubost' </td> <td> where [[doc.]class = 'XWiki.XWikiUsers' and] [doc.]XWiki.XWikiUsers.email like '%xwiki.com' and [doc.]author = 'XWiki.LudovicDubost' </td> <td> , XWiki.XWikiUsers as user where [doc.]id = user.docId and user.email like '%.xwiki.com' and [doc.]author = 'XWiki.LudovicDubost' </td> </tr> <tr> <td> Query with 2 classes </td> <td> where doc.object(XWiki.XWikiUsers).email like '%xwiki.com' and doc.object(XWiki.ArticleClass).content like '%ludovic%' </td> <td> , BaseObject as obj, StringProperty as prop, BaseObject as obj2, LargeStringProperty as contentprop where doc.fullName = obj.name and obj.className = 'XWiki.XWikiUsers' and obj.id=prop.id.id and prop.id.name='email' and prop.value like '%xwiki.com' and doc.fullName=obj2.name and obj2.className='XWiki.ArticleClass' and obj2.id=contentprop.id.id and contentprop.id.name='content' and contentprop.value like '%ludovic%' </td> <td> /*/*[obj/XWiki/XWikiUsers/@xp:email like '%xwiki.com' and obj/XWiki/ArticleClass/@xp:content like '%ludovic%'] </td> <td> from XWiki.XWikiUsers as user, XWiki.ArticleClass as article where user.email like '%xwiki.com' and article.content like '%ludovic%' </td> <td> where [[doc.]XWiki.XWikiUsers and] [[doc.]XWiki.ArticleClass and] [doc.]XWiki.XWikiUsers.email like '%xwiki.com' and [doc.]XWiki.ArticleClass like '%ludovic%' </td> <td> where [[doc.]class = 'XWiki.XWikiUsers' and] [[doc.]class = 'XWiki.ArticleClass' and] [doc.]XWiki.XWikiUsers.email like '%xwiki.com' and [doc.]XWiki.ArticleClass like '%ludovic%' </td> <td> ,XWiki.XWikiUsers as user, XWiki.ArticleClass as article where [doc.]id = user.docId and [doc.]id=article.docId and user.email like '%.xwiki.com' and article.content like '%ludovic%' </td> </tr> </table> | ||
| 18 | |||
| 19 | <table> | ||
| 20 | <tr><td>Query</td><td>XWQL</td><td>HQL</td></tr> | ||
| 21 | <tr> | ||
| 22 | <td>Search blogs per category</td> | ||
| 23 | <td> | ||
| 24 | where doc.fullName <> 'XWiki.ArticleClassTemplate' and :category member of doc.object(XWiki.ArticleClass).category | ||
| 25 | </td> | ||
| 26 | <td> | ||
| 27 | , BaseObject as obj, DBStringListProperty as prop join prop.list list where obj.name=doc.fullName and obj.className='XWiki.ArticleClass' and obj.name<>'XWiki.ArticleClassTemplate' and obj.id=prop.id.id and prop.id.name='category' and list='${category}' order by doc.creationDate desc | ||
| 28 | </td> | ||
| 29 | </tr> | ||
| 30 | <tr> | ||
| 31 | <td>List all tags</td> | ||
| 32 | <td> | ||
| 33 | select distinct obj.tags from Document doc, doc.object(XWiki.TagClass) as obj | ||
| 34 | </td> | ||
| 35 | <td> | ||
| 36 | select distinct tag from BaseObject as obj, DBStringListProperty as prop join prop.list as tag where obj.className='XWiki.TagClass' and obj.id=prop.id.id and prop.id.name='tags' | ||
| 37 | </td> | ||
| 38 | </tr> | ||
| 39 | </table> | ||
| 40 | |||
| 41 | {{/html}} | ||
| 42 | {{/velocity}} |