(I have a simple CRUD API in a DAO pattern implementation.) All operations (save, load, update, delete) have a transaction id that must be supplied. So eg. its possible to do:
…
id = begintransaction(); dao.save(o, id); sao.update(o2, id); rollback(id);
All examples excluding load invocations seems intuitive. But as soon as you start to load objects from the database, things ‘feel’ a little bit different. Are load-operations, per definition, tied to a transaction? Or should my load operations be counted as a single amount of work?
Depends on the transaction isolation level (http://en.wikipedia.org/wiki/Isolation_(database_systems)) you’re using, but in general they should be part of the transaction. What if somebody else is just in the middle of updating the data you’re trying to read? If the read operation is not transactional, you would get old data, and maybe you’re interested in the latest data.