I've been trying to get my head around CMT and been struggling to work out how the Container does the management.
Assume that I'm doing simple non-XA single-datasource database access in
EJB 3.0 and configured the Stateless Session Bean using @TransactionManagement(TransactionManagementType.CONTAINER)
So, when I call a method (methodA), I decide that I need a database connection. So, I use a JNDI lookup to obtain the datasource, get a new connection and do some SQL. The spec says that I mustn't do a commit on the connection, so I finish the code with a connection.close().
My question is, how does the connection know to participate in the transaction that is defined at the SSB level. Presumably, methodA can call methodB which could call similar code, again connecting to the database and doing some more SQL. How does the container co-ordinate this given that I have closed the connection myself?