Re: [xwiki-users] Need HQL query for date comparison

2009-03-09 Thread MaryEllen Coleman


I'm using this query now:  #set($sql = ", BaseObject as obj, $proptype as
prop where obj.className='${ISDclassname}' and obj.id=prop.id.id and
prop.name='${viewby}' and doc.fullName=obj.name and doc.fullName!='$
{ISDclasstemplate}' and $xwiki.getDate()-doc.contentUpdateDate<15 order by
prop.value")

And I am getting this error:  Error number 4001 in 4: Error while parsing
velocity page ISDCenter.WebHome Wrapped Exception: Failed to evaluate
content with id Web Home

Let me guess:  subtracting doc.contentUpdateDate from $xwiki.getDate() is
invalid?  Is there another way that I should manipulate the dates so that I
can determine if a document is too old to display?

Thanks!

   
 Mary Ellen Coleman 
   

   

   

___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Need HQL query for date comparison

2009-03-07 Thread Niels Mayer
I had problems with HQL statements containing parentheses used to help
humans see the logic more easily, but not needed by the logic itself. When I
removed the parentheses and changed the equation to take advantage of
built-in operator precedence...  then it worked.

I'm not saying that is the problem or whether it's an issue with date
comparisons like the use of $xwiki.getDate() is in a date subtraction, or
whether it is missing quotes since the velocity substitutions happen at a
different time thant he HQL evaluation

However, since the problem area is similar to what happened when I had extra
parentheses, perhaps try replacing ($xwiki.getDate() -
doc.contentUpdateDate) < 15
with $xwiki.getDate()-doc.contentUpdateDate<15 ???

For example, the following only worked if I remove all parentheses around
the inequality comparisons:
#set($hqlQuery = ", XWikiRCSNodeInfo as ni where doc.id=ni.id.docId and
ni.id.version2=1 and doc.space<>'XWiki' and doc.space<>'Main' and
doc.space<>'Panels' group by doc.space, doc.name order by max(ni.date)
desc")

(output: http://nielsmayer.com/xwiki/bin/view/Timeline/ChangesList?xpage=rdf
code: http://nielsmayer.com/xwiki/bin/view/Timeline/ChangesList?viewer=code
app using: http://nielsmayer.com/xwiki/bin/view/Timeline/TL2 )

Is this parenthesis behavior a bug? Or is there some special escaping needed
for HQL parentheses?

Niels
http://nielsmayer.com



On Fri, Mar 6, 2009 at 8:18 AM, MaryEllen Coleman  wrote:

> Hello! I need an HQL query that does the following:
>Last modified date should be less than 15 days from today
>
> This is what I've tried:
>#set($sql = ", BaseObject as obj, $proptype as prop where
> obj.className='${ISDclassname}' and obj.id=prop.id.id and
> prop.name='${viewby}' and doc.fullName=obj.name and
> doc.fullName!='${ISDclasstemplate}' and ($xwiki.getDate() -
> doc.contentUpdateDate) < 15 order by prop.value")
>
> But I'm getting an error on the and ($xwiki.getDate() -
> doc.contentUpdateDate) < 15 statement.  What should I write instead?
>
> Mary Ellen Coleman
>
>
> ___
> users mailing list
> users@xwiki.org
> http://lists.xwiki.org/mailman/listinfo/users
>
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users