This is the current schema
when issuing multiple Castor transactions after another:
In this example we create a new JDO, and store it into the
database. After that we query this (or another object) using an
OQL query, change it and store it back into the database.
Note two things:
We call Database.close() to finish the first transaction
cycle.
The JDBC connection, which is managed by Castor
internally, is closed immediatelly when committing the
transaction.
The following picture
shows a way to optimize the operations when using multiple
Castor transactions:
Now we don't close the JDBC session immediatelly in the
commit() (or rollback) call. Instead we move this step into
the close() call.
There is no need to call close() after finishing the
first transaction. The second call to begin() recycles the
transaction object, and keeps using the same JDBC
session.
This way we save the heavy step to re-open a database session
any time we want to begin another transaction.