Alfresco, CMIS and Prepared statement

cancel
Showing results for 
Search instead for 
Did you mean: 
nagatoo
Member II

Alfresco, CMIS and Prepared statement

Jump to solution

Hi guys, my question is: how, using only an CMIS interface, execute prepared statement query?

My code: 

String query = "SELECT org.cmis:objectId FROM supd:orgStructure "
      + "as org WHERE org.cmis:name like ? AND org.supd:orgStructureKind = ?";

   QueryStatement qs = session.createQueryStatement(query);

   qs.setProperty(1, "%"+name+"%");

   qs.setProperty(2, indexkind);



String statement = qs.toQuerySring();
ItemIterable<QueryResult> results = qs.query(false);

Object session include connection settings (serverDB url, etc...). How get this object, using only CMIS?

1 Solution

Accepted Solutions
andy1
Senior Member

Re: Alfresco, CMIS and Prepared statement

Jump to solution

Hi

You do not need to worry about prepared statements.

You are expressing your query in a language that does not support that feature. Underneath the covers your SQL gets parsed and executed against either SOLR or the database. The database execution engine generates SQL which will use prepared statements.

We do have support for parametrised queries in AFTS - but not for the CMIS QL. They do not get used much. They did not make it to the public API for this reason (IIRC).

Andy

View solution in original post

4 Replies
afaust
Master

Re: Alfresco, CMIS and Prepared statement

Jump to solution

I don't understand the question. You are already using CMIS - so what are you asking for when you say "how to get this object using only CMIS"? Do you mean by manually crafting / sending the CMIS HTTP requests, without the OpenCMIS library?

Highlighted
nagatoo
Member II

Re: Alfresco, CMIS and Prepared statement

Jump to solution

Sorry for incorrect question,

Usually, I work with base through searchService: 

   String query = "SELECT org.cmis:objectId FROM supd:orgStructure "
      + "as org WHERE org.cmis:name like" + name + " AND org.supd:orgStructureKind = "

       + indexKind;    

   SearchParameters sp = new SearchParameters();


   sp.addStore(store);
   sp.setLanguage(language);
   sp.setQuery(query);

    ResultSet rs = searchService.query(sp);

   result = rs.getNodeRefs();

    if (rs != null) {
      rs.close();
   }

 

Now i wanna execute prepared statement query, but i dont know how to do this. After googling i search solution described above (in the first post). In solution appears session object:

   QueryStatement qs = session.createQueryStatement(query);

 Make session object == make new connection (if i understand right, and if its true, this solution is not for me).

 Maybe there is an opportunity execute this query in searchService?

afaust
Master

Re: Alfresco, CMIS and Prepared statement

Jump to solution

Within the Repository-tier Java API there is no support for using prepared statements to execute an Alfresco query.

andy1
Senior Member

Re: Alfresco, CMIS and Prepared statement

Jump to solution

Hi

You do not need to worry about prepared statements.

You are expressing your query in a language that does not support that feature. Underneath the covers your SQL gets parsed and executed against either SOLR or the database. The database execution engine generates SQL which will use prepared statements.

We do have support for parametrised queries in AFTS - but not for the CMIS QL. They do not get used much. They did not make it to the public API for this reason (IIRC).

Andy

View solution in original post