Reputation: 1031
From the JCR specification I know that I can request an UserTransaction object (specified in JTA) and create a begin/commit/rollback sequence during the current session. May question is if I can do something similar in Sling? For example, when the user request an url which resolves to my servlet or during my bundle startup.
I can access the JCR Repository but will the transaction mechanism work as its supposed to when resources are concerned (wich may be not be JCR-backed up...)?
And also how does Sling/JCR/Jackrabbit with both "transaction controlled" sessions and not "transaction controlled" at one time? Could this kind of behavior bring some inconsistencies to the repository if something goes wrong?
Upvotes: 1
Views: 631
Reputation: 6100
Do you really need transactions? The JCR Session's transient space works well as a lightweight transaction mechanism, if you close the session without calling save() all changes will be thrown away. The usual pattern is to do stuff in the servlets or scripts that handle your request, and only save if said stuff was successful.
On the other hand, Sling provides full access to the underlying JCR Session, so you should be able do anything suitable. If not, best is to ask on the Sling users lists, see http://sling.apache.org/site/project-information.html#ProjectInformation-lists
Upvotes: 1