You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by sbarriba <sb...@yahoo.co.uk> on 2008/11/06 11:59:23 UTC
SYSDATE() or NOW() concept in JCR query?
Hi all,
We want to be able to query a set of nodes that have a date property which
is earlier than the current date.
Is there a function facility within JCR SQL or XPath which will be replaced
with the current time/date?
I can do it by creating a literal date in Java to achieve.
xpathquery "/jcr:root/home/entries//element(*,
acm:BlogEntry)[@acm:publishdate <
xs:dateTime(\'2008-11-05T00:00:00.000+01:00\')]"
.but I'd rather simply do..
xpathquery "/jcr:root/home/acmenodes//element(*,
acm:BlogEntry)[@acm:publishdate < sysdate()]"
All help appreciated.
Regards,
Shaun
Re: SYSDATE() or NOW() concept in JCR query?
Posted by Phil Weighill-Smith <ph...@volantis.com>.
I take it that Jackrabbit has no framework to allow custom functions to
be added to the XPath (subset)?
Phil :n.
On Fri, 2008-11-07 at 13:43 +0100, Alexander Klimetschek wrote:
> Hi!
>
> No, this function is not supported. The XPath defined by JCR is only a
> subset of XPath 1.0 and the only functions that are required are
> jcr-specifc (jcr:like, jcr:contains, jcr:deref, jcr:score and some of
> the Jackrabbit search extensions, such as rep:similar [1]). See also
> section 6.6.5 and 6.6.6 of the JSR-170 spec [2].
>
> JCR 2.0 will no longer have XPath out of the box, but a java query
> model (JCR-JQOM). This means there will most likely be a generic XPath
> to JQOM converter that could be more easily and separately maintained
> and support such simple functions (as this only means to replace the
> current-dateTime() with the date value).
>
> For now you could do either do it manually in your Java code or, if
> you want to manually enter queries, you could write a simple wrapper
> that simply replaces the "current-dateTime()" string with the value of
> the current date. (I know, this solution won't work for all
> functions...)
>
> [1] http://wiki.apache.org/jackrabbit/Search
> [2] http://jcp.org/en/jsr/detail?id=170
>
> Regards,
> Alex
>
>
> On Fri, Nov 7, 2008 at 12:30 PM, Phil Weighill-Smith
> <ph...@volantis.com> wrote:
> > XPath 2.0 has a current-dateTime() function, but don't know if it's
> > available in Jackrabbit's implementation.
> >
> > Phil :n)
> >
> > On Thu, 2008-11-06 at 10:59 +0000, sbarriba wrote:
> >
> >> Hi all,
> >>
> >> We want to be able to query a set of nodes that have a date property which
> >> is earlier than the current date.
> >>
> >>
> >>
> >> Is there a function facility within JCR SQL or XPath which will be replaced
> >> with the current time/date?
> >>
> >>
> >>
> >> I can do it by creating a literal date in Java to achieve.
> >>
> >> xpathquery "/jcr:root/home/entries//element(*,
> >> acm:BlogEntry)[@acm:publishdate <
> >> xs:dateTime(\'2008-11-05T00:00:00.000+01:00\')]"
> >>
> >>
> >>
> >> .but I'd rather simply do..
> >>
> >> xpathquery "/jcr:root/home/acmenodes//element(*,
> >> acm:BlogEntry)[@acm:publishdate < sysdate()]"
> >>
> >>
> >>
> >> All help appreciated.
> >>
> >> Regards,
> >>
> >> Shaun
> >>
> >>
> >>
> >>
> >>
> >
>
>
>
Re: SYSDATE() or NOW() concept in JCR query?
Posted by Alexander Klimetschek <ak...@day.com>.
Hi!
No, this function is not supported. The XPath defined by JCR is only a
subset of XPath 1.0 and the only functions that are required are
jcr-specifc (jcr:like, jcr:contains, jcr:deref, jcr:score and some of
the Jackrabbit search extensions, such as rep:similar [1]). See also
section 6.6.5 and 6.6.6 of the JSR-170 spec [2].
JCR 2.0 will no longer have XPath out of the box, but a java query
model (JCR-JQOM). This means there will most likely be a generic XPath
to JQOM converter that could be more easily and separately maintained
and support such simple functions (as this only means to replace the
current-dateTime() with the date value).
For now you could do either do it manually in your Java code or, if
you want to manually enter queries, you could write a simple wrapper
that simply replaces the "current-dateTime()" string with the value of
the current date. (I know, this solution won't work for all
functions...)
[1] http://wiki.apache.org/jackrabbit/Search
[2] http://jcp.org/en/jsr/detail?id=170
Regards,
Alex
On Fri, Nov 7, 2008 at 12:30 PM, Phil Weighill-Smith
<ph...@volantis.com> wrote:
> XPath 2.0 has a current-dateTime() function, but don't know if it's
> available in Jackrabbit's implementation.
>
> Phil :n)
>
> On Thu, 2008-11-06 at 10:59 +0000, sbarriba wrote:
>
>> Hi all,
>>
>> We want to be able to query a set of nodes that have a date property which
>> is earlier than the current date.
>>
>>
>>
>> Is there a function facility within JCR SQL or XPath which will be replaced
>> with the current time/date?
>>
>>
>>
>> I can do it by creating a literal date in Java to achieve.
>>
>> xpathquery "/jcr:root/home/entries//element(*,
>> acm:BlogEntry)[@acm:publishdate <
>> xs:dateTime(\'2008-11-05T00:00:00.000+01:00\')]"
>>
>>
>>
>> .but I'd rather simply do..
>>
>> xpathquery "/jcr:root/home/acmenodes//element(*,
>> acm:BlogEntry)[@acm:publishdate < sysdate()]"
>>
>>
>>
>> All help appreciated.
>>
>> Regards,
>>
>> Shaun
>>
>>
>>
>>
>>
>
--
Alexander Klimetschek
alexander.klimetschek@day.com
Re: SYSDATE() or NOW() concept in JCR query?
Posted by Phil Weighill-Smith <ph...@volantis.com>.
XPath 2.0 has a current-dateTime() function, but don't know if it's
available in Jackrabbit's implementation.
Phil :n)
On Thu, 2008-11-06 at 10:59 +0000, sbarriba wrote:
> Hi all,
>
> We want to be able to query a set of nodes that have a date property which
> is earlier than the current date.
>
>
>
> Is there a function facility within JCR SQL or XPath which will be replaced
> with the current time/date?
>
>
>
> I can do it by creating a literal date in Java to achieve.
>
> xpathquery "/jcr:root/home/entries//element(*,
> acm:BlogEntry)[@acm:publishdate <
> xs:dateTime(\'2008-11-05T00:00:00.000+01:00\')]"
>
>
>
> .but I'd rather simply do..
>
> xpathquery "/jcr:root/home/acmenodes//element(*,
> acm:BlogEntry)[@acm:publishdate < sysdate()]"
>
>
>
> All help appreciated.
>
> Regards,
>
> Shaun
>
>
>
>
>