Querying Repository (Filesystem Connector) return only Root node
penkween Sep 12, 2011 6:26 AMHi,
I am using Modeshape-2.6.0-b2 on a File System Repository which having multiple level of folder (nt:folder) an files (nt:file) and all these nodes can indeed be dump out correctly using getNode().
Currently I am testing "Query" using JCR-SQL2 and I am having problem with query like "SELECT * FROM [nt:base]" where it doesn't return all the nodes and query like "SELECT * FROM [nt:file]" even return empty ResultSet . Belows showing the codes and errors:
Thanks a lot for your help.
Note:
- This output behavior is identical if I use xpath
Codes
=============================================================================================
InitialContext initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
Repository repository = (Repository) envCtx.lookup("jcr/local");
System.out.println("Repository = " + repository); //For Debug
Session session = repository.login(new ServletCredentials(request)); //This has indeed login OK since I can dump node info
QueryManager queryManager = session.getWorkspace().getQueryManager();
String language = null;
String expression = null;
Query query = null;
QueryResult result = null;
language = "JCR-SQL2"; | |
expression = "SELECT * FROM [nt:base]"; | |
query = queryManager.createQuery(expression, language); | |
result = query.execute(); | |
System.out.println("########################################################################################################"); | |
System.out.println("Language = " + language + "\tExpression = " + expression); | |
System.out.println("########################################################################################################"); | |
System.out.println(result.toString()); |
language = "JCR-SQL2"; | |
expression = "SELECT * FROM [nt:file]"; | |
query = queryManager.createQuery(expression, language); | |
result = query.execute(); | |
System.out.println("########################################################################################################"); | |
System.out.println("Language = " + language + "\tExpression = " + expression); | |
System.out.println("########################################################################################################"); | |
System.out.println(result.toString()); |
session.logout();
Errors
=============================================================================================
INFO: JcrEngine starting...
INFO: JcrEngine started in 2768 ms
INFO: Completed starting the "MyFileSystemRepository" repository
INFO: Repository = org.modeshape.jcr.JcrRepository@20d219
INFO: ########################################################################################################
INFO: Language = JCR-SQL2 Expression = SELECT * FROM [nt:base]
INFO: ########################################################################################################
INFO: +---+-----------------+----------+----------+-----------+----------------+------------+------------------------------------------------------------------------------------+----------------+
| # | jcr:primaryType | jcr:path | jcr:name | jcr:score | mode:localName | mode:depth | Location(nt:base) | Score(nt:base) |
+---+-----------------+----------+----------+-----------+----------------+------------+------------------------------------------------------------------------------------+----------------+
| 1 | mode:root | / | | 1.0 | | 0 | </ && [{http://www.modeshape.org/1.0}uuid = fd129c12-81a8-42ed-aa4b-820dba49e6f1]> | 1.0 |
+---+-----------------+----------+----------+-----------+----------------+------------+------------------------------------------------------------------------------------+----------------+
INFO: ########################################################################################################
INFO: Language = JCR-SQL2 Expression = SELECT * FROM [nt:file]
INFO: ########################################################################################################
INFO: +---+-----------------+-------------+---------------+----------+----------+-----------+----------------+------------+-------------------+----------------+
| # | jcr:primaryType | jcr:created | jcr:createdBy | jcr:path | jcr:name | jcr:score | mode:localName | mode:depth | Location(nt:file) | Score(nt:file) |
+---+-----------------+-------------+---------------+----------+----------+-----------+----------------+------------+-------------------+----------------+
+---+-----------------+-------------+---------------+----------+----------+-----------+----------------+------------+-------------------+----------------+