AnsweredAssumed Answered

Is JCR-XPATH-SQL supported by alfresco repository?

Question asked by amit_wmw@yahoo.com on May 4, 2009
Hello,

I am getting error while executing below program to query and find content. Can anybody please suggest that whether my query is incorrect or is it that Alfresco doesn't supports JCR-XPATH-SQL at all? I am able to achive the result through XPATH but my requirment is to do the same through JCR-XPATH-SQL.



Sample program
—————————
public class FirstJCRClient
{
   

  
   public static void main(String[] args)      
   {
   
      try{
         
         
         
          ApplicationContext context = new ClassPathXmlApplicationContext("classpath:alfresco/application-context.xml");
      
          Repository repository = (Repository)context.getBean("JCR.Repository");
         
          Session session = repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
        
         
        
          try {
         
              Workspace workspace=session.getWorkspace();
             
            
             
              QueryManager queryManager=workspace.getQueryManager();
             
            
          
Query query = queryManager.createQuery("select * from app:company_home where @cm:author='Kumar'", Query.SQL

// Query query = queryManager.createQuery("//app:company_home//element(*, cm:content) [jcr:contains(@cm:author, 'AMit')]", Query.XPATH);   
                                             

              QueryResult queryResult=query.execute();                                                              
             
             
             
               NodeIterator nodeIterator=queryResult.getNodes();

               while(nodeIterator.hasNext()) {
                   
                   Node node=nodeIterator.nextNode();
                 
                   Property p=node.getProperty("cm:name");
                  
                   System.out.println("———>>>>"+p.getValue().getString());
                  
                   }
              
           } catch(Exception e) {
               e.printStackTrace();
           }

finally
{
session.logout();
System.exit(0);
}

}
catch (Exception exp ){
System.out.println (" Caught exception " + exp);
exp.printStackTrace();
}
}
}


Error
——-

javax.jcr.query.InvalidQueryException: Query language sql is not supported
   at org.alfresco.jcr.query.QueryManagerImpl.createQuery(QueryManagerImpl.java:79)
   at org.alfresco.sample.FirstJCRClient.main(FirstJCRClient.java:68)

Please suggest.

Thanks
Amit.

Outcomes