Transactions

commiting changes

At the moment, Daobab supports transaction for DataBaseTarget only. Any other targets doesn't support transactions yet.


The simplest usage

Method execute() surrounds operation into internal transaction. This process is automated.

Daobab opens before and close transaction after each modification (insert, update, modify) is being called.


Inserting a single Category record:

Wrapping more operations

It's possible to execute more operations into a single transaction, with transaction wrapper.


Method wrapTransaction exposes t as a OpenTransactionTarget based on db target:

Above two examples covers the majority of cases.

However if you want commit or rollback transaction on your terms, you may do this as well.

DataBaseTarget provides a beginTransaction() method, which produces another one target references, which extends the current one with opened transaction.

You have to relate your queries to the transaction target, if you want to wrap the operations into his transaction scope.

It's up yo you, when commit or rollback will be invoked.

Daobab transactions are no-scoped. They are not related to a single threat. The transaction stage is under transaction target.
That's a big benefit according to well-known all annotation-based transactions, which scope is located mostly under ThreadLocal and this brings a lot of limitations into response programming.
Not to mention that annotations cannot be used into interfaces, so whole functional programming is limited as well.

You may provide a transaction target to any thread or scope.
You may open transactional target in different threat which is closing it.

This approach may works fine into functional consumers for example. 

Share This Page

FACEBOOK COMMENTS WILL BE SHOWN ONLY WHEN YOUR SITE IS ONLINE

©Elephant Software Klaudiusz Wojtkowiak
e-mail: contact@daobab.io