June 20th 2008 12:50 pm
SUPPORTS propagation is used by wimps
Everywhere is said that the default propagation behavior is or should be REQUIRED. Now, in (my) web applications, most of the service layer methods just reads, i.e. return data fetched somehow from the database (speaking in general). I could not ask myself: why then I need a transaction for reading? Why I can’t use SUPPORTS propagation behavior? Shouldn’t SUPPORTS be faster when just reading?
Since I am using spring+hibernate (and tx annotations processed by aspect), I checked spring documentation, as well as other resources. Nothing much found, except:
“Note: For transaction managers with transaction synchronization, PROPAGATION_SUPPORTS is slightly different from no transaction at all, as it defines a transaction scopp that synchronization will apply for. As a consequence, the same resources (JDBC Connection, Hibernate Session, etc) will be shared for the entire specified scope. Note that this depends on the actual synchronization configuration of the transaction manager.”
So what, I said, my framework stack should handle it without problems. I did some quick tests and found out not only that SUPPORTS works, but it is really faster: some simple ‘long-loop’ test returns 10.7 seconds for REQUIRED and 8.4 seconds for SUPPORTS propagation behavior.
So does anyone know why I should not use SUPPORTS for services that just read? Or is this one of those ’shut-up and do as we told you’ questions?
If you enjoyed this post, make sure you subscribe to my RSS feed!
No Comments yet »