You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Michal Hybler <m....@email.cz> on 2007/03/14 16:09:42 UTC
searching nodes
I have method for searching nodes by id.
In this method i gel all nodes by SQL search
query = manager.createQuery("select * from nt:unstructured ",Query.SQL);
QueryResult result = query.execute();
and after that iterate by while cycle for node
while(it.hasNext()){
Node node = it.nextNode();
if (node.getName().length() != 0){
if (getId(node).equals(id)) {
return new Polozka(node.getUUID(),node.getName());
}
--- getId is my method represents node.getUUID() and Polozka id my class
represents node.---
but this method is so slow some has better solution fo searching nodes by
Id?
Thanks for help Michal Hybler
--
View this message in context: http://www.nabble.com/searching-nodes-tf3402715.html#a9476370
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
Re: searching nodes
Posted by Christoph Kiehl <ch...@sulu3000.de>.
Michal Hybler wrote:
> I have method for searching nodes by id.
>
> In this method i gel all nodes by SQL search
>
> query = manager.createQuery("select * from nt:unstructured ",Query.SQL);
> QueryResult result = query.execute();
> and after that iterate by while cycle for node
>
> while(it.hasNext()){
> Node node = it.nextNode();
> if (node.getName().length() != 0){
> if (getId(node).equals(id)) {
> return new Polozka(node.getUUID(),node.getName());
> }
> --- getId is my method represents node.getUUID() and Polozka id my class
> represents node.---
>
> but this method is so slow some has better solution fo searching nodes by
> Id?
> Thanks for help Michal Hybler
What does getId(node) do? I suppose it calls getProperty() on the given node. Is
that right? In that case you should extend your query to include the id
restriction. If your property name for example is "foo:bar" this would like this:
"select * from nt:unstructured where foo:bar='" + id + "'"
This will only return nodes which property foo:bar is set to id.
Cheers,
Christoph