• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

longterm connections in a bean's lifetime

 
David Yuan
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I read in some Notes that for code brevity's sake, one can create a connection in ebjCreate (for SB) or setEntityContext (for EB), and close the connection in ejbRemove(for SB) or unsetEntityContext (for EB).
I never did that in my programming, so I am curirous that if we do this, how can we manage the transaction? If we use CMT, will the connection automatically enlist in the Tx in each busines method? And if we use BMT, how can we enlist the connection at the beginning of each business method and unenlist it before exiting?
A code snippet would be appreciated!
-David.
 
David Yuan
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found some code snippet from the section of "17.3.3 Enterprise Beans Using Bean-Managed Transaction Demarcation" of EJB spec 2.1.
Basically it demonstrate how the BMT get the UserTransaction with a call to ejbContext.getUserTransaction(), and get the connection factory from JNDI. I didn't see any code to enlist the connection in the UserTransaction. There I assume it is enlisted automatically. Right? (Sorry if this is a newbie question since I am from a COM+/DTC background. )
-David
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic