| Sign In/My Account | View Cart |
| Article: |
Bean-Managed Transaction Suspension in J2EE | |
| Subject: | Point? | |
| Date: | 2005-07-21 21:45:02 | |
| From: | hbarua | |
| IMHO, the reason there was a UserTransaction interface was to clearly separate out the roles and responsibilities of BMTs and CMTs. Forcibly trying to extract the TM probably indicates that the app is not configured properly for transactions. If the J2EE spec does mandate exposing the TM in future versions of the spec that would of course be useful to frameworks like Spring (and also most of the OR mapping tools which use transactions). The tricks described here would just lead to non portable applications, apart from leading to possible inconsistencies. | ||
Showing messages 1 through 8 of 8.
I am using POJO Entities that coordinate with JPA and UserTransaction for ORM. On top of that, I want POJO DAOs that emulate CMT.
I do not want EJBs. I do not need to remote my objects. I do not want to write tons of interfaces and classes for every DAO. No thanks.
My POJO DAOs will use my own custom Annotations that emulate javax.ejb.TransactionAttribute. Using Spring and AspectJ and advice in this article, I now have an idea of how to write my advice blocks.
And THAT is the point. I don't want to sacrifice the ease of declarative transaction demarcation just because my software needs do not justify the heavyness of the rest of EJBs.
Moreover I hoped to bring a little bit more light how Spring makes 'transactional proxies' functionality work, because I think it's important for developers to understand internal 'kitchen' of framework they're using and possible problems/limitations it imposes.
J2EE spec is not a dogma, and looking up TM doesn't make your code less portable than say using container-specific deployment descriptors. Even so in this article sample code to lookup TM intentionally simplified, there is a perfectly legal way to do it without introducing dependencies on any container-specific classes so your code would work in any container (see Spring sources for details if interested).