You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by "Conoly, Brett" <Br...@digitalinsight.com> on 2008/03/28 20:27:25 UTC

LIMIT in SQL queries

Hey all, 

I'm currently trying to implement a method that will return a
NodeIterator from the repository based on an SQL query that I pass it.
The only problem right now is that I can't seem to find the equivalent
of the SQL LIMIT function.  Does anyone happen to know if there is
equivalent functionality or an alternative to do what I'm looking for?

Thanks in advance,

Brett

 


Re: LIMIT in SQL queries

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

On Fri, Mar 28, 2008 at 10:45 PM, Conoly, Brett
<Br...@digitalinsight.com> wrote:
> I really do appreciate your help and I hate to bug you too much but I
>  tried implementing your suggestion and it seems that jackrabbit's rmi
>  Query implementation does not implement the setLimit or setOffset
>  functions.  Am I just looking in the wrong place?

The RMI layer does not currently support he setLimit and setOffset methods.

> Does anyone have any clue of an equivalent rmi query that will work for me?

The pure JCR 1.0 way to simulate offset/limit is the following:

    QueryResult result = ...;
    NodeIterator nodes = result.getNodes();
    nodes.skip(...);
    for (int i = 0; i < ... && nodes.hasNext(); i++) {
        nodes.nextNode();
    }

BR,

Jukka Zitting

RE: LIMIT in SQL queries

Posted by "Conoly, Brett" <Br...@digitalinsight.com>.
I really do appreciate your help and I hate to bug you too much but I
tried implementing your suggestion and it seems that jackrabbit's rmi
Query implementation does not implement the setLimit or setOffset
functions.  Am I just looking in the wrong place? Does anyone have any
clue of an equivalent rmi query that will work for me?
Thanks again

-----Original Message-----
From: Martin Zdila [mailto:m.zdila@mwaysolutions.com] 
Sent: Friday, March 28, 2008 4:19 PM
To: users@jackrabbit.apache.org
Subject: Re: LIMIT in SQL queries

hi brett

afaik it is planned for the JCR 2. see 
http://wiki.apache.org/jackrabbit/Proposed_JCR_2.0_API_Changes

cu

On Fri 28. March 2008 20:38:06 Conoly, Brett wrote:
> Awesome, I don't know that I ever would have found that.  My only
> question is does anyone know if there are plans to make the LIMIT
> functionality a requirement for all JCR implementations?  In other
words
> so it will be portable among all JSR-170 compliant repositories?
> Thanks again,
> Brett
>
>
> -----Original Message-----
> From: Martin Zdila [mailto:m.zdila@mwaysolutions.com]
> Sent: Friday, March 28, 2008 3:31 PM
> To: users@jackrabbit.apache.org
> Subject: Re: LIMIT in SQL queries
>
> hi brett
>
> final Query query =
> session.getWorkspace().getQueryManager().createQuery(queryString,
> Query.XPATH);
> ((QueryImpl) query).setLimit(limit);
> ((QueryImpl) query).setOffset(offset);
> final QueryResult queryResult = query.execute();
> final long totalSize = ((QueryResultImpl) queryResult).getTotalSize();
>
> cu
>
> On Fri 28. March 2008 20:27:25 Conoly, Brett wrote:
> > Hey all,
> >
> > I'm currently trying to implement a method that will return a
> > NodeIterator from the repository based on an SQL query that I pass
it.
> > The only problem right now is that I can't seem to find the
equivalent
> > of the SQL LIMIT function.  Does anyone happen to know if there is
> > equivalent functionality or an alternative to do what I'm looking
for?
> >
> > Thanks in advance,
> >
> > Brett

-- 
Martin Zdila 
CTO

M-Way Solutions Slovakia s.r.o.
Letna 27, 040 01 Kosice
Slovakia

tel:+421-908-363-848
mailto:m.zdila@mwaysolutions.com
http://www.mwaysolutions.com
xmpp:zdila@jabbim.sk (Jabber)
skype:m.zdila

Re: LIMIT in SQL queries

Posted by Martin Zdila <m....@mwaysolutions.com>.
hi brett

afaik it is planned for the JCR 2. see 
http://wiki.apache.org/jackrabbit/Proposed_JCR_2.0_API_Changes

cu

On Fri 28. March 2008 20:38:06 Conoly, Brett wrote:
> Awesome, I don't know that I ever would have found that.  My only
> question is does anyone know if there are plans to make the LIMIT
> functionality a requirement for all JCR implementations?  In other words
> so it will be portable among all JSR-170 compliant repositories?
> Thanks again,
> Brett
>
>
> -----Original Message-----
> From: Martin Zdila [mailto:m.zdila@mwaysolutions.com]
> Sent: Friday, March 28, 2008 3:31 PM
> To: users@jackrabbit.apache.org
> Subject: Re: LIMIT in SQL queries
>
> hi brett
>
> final Query query =
> session.getWorkspace().getQueryManager().createQuery(queryString,
> Query.XPATH);
> ((QueryImpl) query).setLimit(limit);
> ((QueryImpl) query).setOffset(offset);
> final QueryResult queryResult = query.execute();
> final long totalSize = ((QueryResultImpl) queryResult).getTotalSize();
>
> cu
>
> On Fri 28. March 2008 20:27:25 Conoly, Brett wrote:
> > Hey all,
> >
> > I'm currently trying to implement a method that will return a
> > NodeIterator from the repository based on an SQL query that I pass it.
> > The only problem right now is that I can't seem to find the equivalent
> > of the SQL LIMIT function.  Does anyone happen to know if there is
> > equivalent functionality or an alternative to do what I'm looking for?
> >
> > Thanks in advance,
> >
> > Brett

-- 
Martin Zdila 
CTO

M-Way Solutions Slovakia s.r.o.
Letna 27, 040 01 Kosice
Slovakia

tel:+421-908-363-848
mailto:m.zdila@mwaysolutions.com
http://www.mwaysolutions.com
xmpp:zdila@jabbim.sk (Jabber)
skype:m.zdila

RE: LIMIT in SQL queries

Posted by "Conoly, Brett" <Br...@digitalinsight.com>.
Awesome, I don't know that I ever would have found that.  My only
question is does anyone know if there are plans to make the LIMIT
functionality a requirement for all JCR implementations?  In other words
so it will be portable among all JSR-170 compliant repositories?
Thanks again, 
Brett


-----Original Message-----
From: Martin Zdila [mailto:m.zdila@mwaysolutions.com] 
Sent: Friday, March 28, 2008 3:31 PM
To: users@jackrabbit.apache.org
Subject: Re: LIMIT in SQL queries

hi brett

final Query query =
session.getWorkspace().getQueryManager().createQuery(queryString,
Query.XPATH);
((QueryImpl) query).setLimit(limit);
((QueryImpl) query).setOffset(offset);
final QueryResult queryResult = query.execute();
final long totalSize = ((QueryResultImpl) queryResult).getTotalSize();

cu

On Fri 28. March 2008 20:27:25 Conoly, Brett wrote:
> Hey all,
>
> I'm currently trying to implement a method that will return a
> NodeIterator from the repository based on an SQL query that I pass it.
> The only problem right now is that I can't seem to find the equivalent
> of the SQL LIMIT function.  Does anyone happen to know if there is
> equivalent functionality or an alternative to do what I'm looking for?
>
> Thanks in advance,
>
> Brett

-- 
Martin Zdila 
CTO

M-Way Solutions Slovakia s.r.o.
Letna 27, 040 01 Kosice
Slovakia

tel:+421-908-363-848
mailto:m.zdila@mwaysolutions.com
http://www.mwaysolutions.com
xmpp:zdila@jabbim.sk (Jabber)
skype:m.zdila

Re: LIMIT in SQL queries

Posted by Martin Zdila <m....@mwaysolutions.com>.
hi brett

final Query query = session.getWorkspace().getQueryManager().createQuery(queryString, Query.XPATH);
((QueryImpl) query).setLimit(limit);
((QueryImpl) query).setOffset(offset);
final QueryResult queryResult = query.execute();
final long totalSize = ((QueryResultImpl) queryResult).getTotalSize();

cu

On Fri 28. March 2008 20:27:25 Conoly, Brett wrote:
> Hey all,
>
> I'm currently trying to implement a method that will return a
> NodeIterator from the repository based on an SQL query that I pass it.
> The only problem right now is that I can't seem to find the equivalent
> of the SQL LIMIT function.  Does anyone happen to know if there is
> equivalent functionality or an alternative to do what I'm looking for?
>
> Thanks in advance,
>
> Brett

-- 
Martin Zdila 
CTO

M-Way Solutions Slovakia s.r.o.
Letna 27, 040 01 Kosice
Slovakia

tel:+421-908-363-848
mailto:m.zdila@mwaysolutions.com
http://www.mwaysolutions.com
xmpp:zdila@jabbim.sk (Jabber)
skype:m.zdila