users@glassfish.java.net

Re: Sharing a Connection between EJB's

From: <glassfish_at_javadesktop.org>
Date: Mon, 22 Oct 2007 21:36:08 PDT

Within a transaction, when EJB1 calls EJB2 and EJB2 also acquires a connection, connection sharing will happen. i.e., same physical connection as that of EJB1 will be used.

Refer
https://glassfish.dev.java.net/javaee5/docs/DG/beamj.html#beams
http://blogs.sun.com/JagadishPrasath/entry/connectionsharinginglassfish

eg:

Tx : Container Managed
TxAttribute : REQUIRED

EJB1.method1()
{
acquireConnection()
doDBOperaitons()
closeConnection();
ejb2.method2();
}

Tx : Container Managed
TxAttribute : REQUIRED

EJB2.method2()
{
acquireConnection() // will get same physical connection as EJB1.method1().
}
[Message sent by forum member 'jr158900' (jr158900)]

http://forums.java.net/jive/thread.jspa?messageID=241605