As a general practice, when developing Webscripts that only read data:
I know that in Hibernate / JDBC, the answer is to always create a transaction:
java - Why do I need Transaction in Hibernate for read only operation? - Stack Overflow
But I'm not sure how concepts like that apply to Alfresco webscripts and Alfresco transactions.
VR,
David
It depends on two-three questions:
- Are you working with DB data? (Some Alfresco operations may not necessarily need to check any data managed in the DB)
- Are you performing more than two operations on Alfresco service API layer? (This includes loading data in JavaScript part of web script and then accessing the data again for rendering in FreeMarker)
- Do you need those operations to be consistent with regards to the DB state?
If all three questions are answered with yes then you should set the transaction on the web script layer. Otherwise Alfresco will automatically create small transactions when necessary, e.g. when you call services that deal with DB data (which are most of them).
I recommend always setting the transaction. It doesn't hurt performance and it is way more efficient to have one transaction than to potentially have multiple, automatically created ones.
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.