Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Q: transaction mgt in session bean wrapping JDBC

 
Yan Zhou
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have some confusion as to what happens in a session bean that makes JDBC calls.

Say a stateless session bean has "Required" transaction attribute on its bussiness method, this method uses JNDI to look up data source and get a connection, and then updates database.

How would a J2EE container know this connection is part of the EJB's transaction? Is this something required by J2EE
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basically yes it is required. When the App Server provides transaction processing, it has to monitor the entire transaction and provide all the necessary means to hold everything within the method, including JDBC stuff within that transaction.

I would suggest that the stuff done to the database be put into a POJO, most likely a DAO object, than hvaing that code directly in the Session Bean.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic