I am building a jcr query and receive data from repository. Here is my code:
String queryString = "SELECT * FROM public:hours";
try {
// get session
Session session = requestContext.getSession();
// create query from queryString constructed
Query q = session.getWorkspace().getQueryManager().createQuery(queryString, Query.JCR_SQL2);
// execute query and retrieve result
QueryResult result = q.execute();
// debug line
log.error("query is", q.getStatement());
....
But this can not execute successfully. It gives me an error that
Repositorty Failed:
[INFO] [talledLocalContainer] javax.jcr.query.InvalidQueryException: Query:
[INFO] [talledLocalContainer] SELECT * FROM public:(*)hours; expected: <end>
In the jcr-shell, it works if I type in query sql "select * from public:hours"
and will give me proper results.
I searched many references but almost every example is the same as mine. so I am not sure where the problem is.
Anyone have experience with this please help.
Please see the last line in my code, which is `log.error("query is", q.getStatement());` it gives me an result of `query statement is` with nothing follows. So I am wondering I still didnt build the query correctly? Thank you – Allan Jiang Feb 21 '12 at 02:19