PDA

View Full Version : EJB transaction and Spring templates


pinglu
Sep 14th, 2004, 05:01 PM
Hi,
Can I use jdbcTemplate or HibernateTemplate or support under SLSB transaction hood? ( for example company need expose to remote EJB client), I like the spring handle exception.


Ping

Rod Johnson
Sep 15th, 2004, 04:08 AM
Yes. You could also consider using Spring tx mgt and making the bean BMT, but you can use EJB CMT fine.

pinglu
Sep 15th, 2004, 04:28 PM
I like your second suggestion, you know "political" presure to use EJB, so I can used "EJB" with everything spring under it.

Rod Johnson
Sep 16th, 2004, 11:59 AM
EJB remoting + Spring declarative tx mgt works very well. That way you get Spring's "rollback rule" support, meaning that automatical rollback can work for checked exceptions without propagating an EJBContext through POJO delegates, making them harder to test. Less invasive: transaction management is purely driven through pure Java message signatures.

msauer
Sep 17th, 2004, 02:28 PM
The only ramification I have encountered to using the BMT approach is that your EJB will not be able to be called by another EJB and participate in that bean's transaction. In the section on bean-managed transaction demarcation the EJB spec says "When a client invokes a business method via the enterprise bean’s home or component interface, the Container suspends any transaction that may be associated with the client request."
In my testing, if I had a CMT bean call my Spring transaction bean fronted by a BMT, a rollback initiated in the called bean did not cause a rollback of the caller. This may or may not be an issue for you.
If my understanding of the scenario is not correct, please let me know.