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?
Solved! Go 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
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?
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?
Within the Repository-tier Java API there is no support for using prepared statements to execute an Alfresco query.
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
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.