jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christoph Kiehl <christ...@sulu3000.de>
Subject Re: searching nodes
Date Wed, 14 Mar 2007 16:30:59 GMT
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


Mime
View raw message