Hello All...I am looking for a little guidance on determining exactly how jBPM handles persistance. I found a decent excerpt but I wonder if anyone could tell me a little more about what the "JbpmContext" is:
Database and transactions
The basic jBPM workings do not require any persistency, it is an optional step to make process definitions and instances persistent. This is done by surrounding the jBPM operations with the retrieval of a "JbpmContext" and using its methods to persist the entities.
A JbpmContext requires closing, which will close the services managed by the context, among which the "PersistenceService", and upon closing this service, the database transaction will be committed, or rolled back if JbpmContext.setRollbackOnly() was called. (The PersistenceService by default starts a transaction when the database connection is first retrieved).
So it is upon us (of course) to call JbpmContext.setRollbackOnly() in case an exception occurs, where we don't want things to persist.
If we want to do things in the same database transaction as jBPM, we can do this inside the same JbpmContext retrieve/close block, by getting the connection using JbpmContext.getConnection() or the hibernate session using JbpmContext.getSession().
The jBPM context is kind of to jBPM what a hibernate session is to hibernate. Instead of retrieving the hibernate session with JbpmContext.getSession() you can also inject your own session with JbpmContext.setSession(....)