11-02-2017 02:19 AM
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?
11-03-2017 02:33 AM
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
11-02-2017 05:13 AM
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?
11-02-2017 05:48 AM
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?
11-02-2017 07:27 AM
Within the Repository-tier Java API there is no support for using prepared statements to execute an Alfresco query.
11-03-2017 02:33 AM
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
Explore our Alfresco products with the links below. Use labels to filter content by product module.