GlassFish is managing your connection
pool and Transactions. (or it should be) So long as you have your transaction
boundaries defined on your EJB's a transaction should be started for you
by the container on each method invocation. Even if you don't explicitly
define a transaction boundary with the @Transaction annotation, the containers
default behavior is to start a transaction on method invocation of the
EJB. So a transaction should be started if one doesn't exist. The enlistment
of the connection within the transaction is handled by the container as
it is managing the connection pool. Every time a connection is retrieved
from the pool, it will be enlisted within the running transaction. (Unless
you explicitly suspend the running transaction)
The connection pool has configuration
options. As I stated, one is for associating the connection to the running
thread of execution. This allows the connection to be reused each time
a connection is requested by the thread. Another configuration of the pool
is to allow non-transactional connections, which allows callers that are
not within a transaction to retrieve a connection from the pool. This option
should not be checked and will cause an exception to be thrown
if a non-transactional caller requests a connection. So basically, if it
is unchecked and your are retrieving connections from the pool and no exception
is thrown, then all connections are operating within a running transaction.
I hope this helps clarify.
Chris Mathrusse
christopher.mathrusse@...
Sybase, Inc
Christopher.Mathrusse@... a écrit :
> There is a configuration on the Connection Pool in Glassfish that
> allows you to associated the connection to the current thread of
> execution. This will allow for the connection to be reused when it
is
> requested. Take a look at the ConnectionPool and check this option.
>
I think the connections are reused: though connections seem to be
acquired a lot of times, there are only few actual new db connections.
What I'd like to ensure is that all those queries, which are really
being made for the same use case, are in the same transaction. How to do
that?
Perhaps I misunderstood and your suggestion could help us. Could you
tell us more details?
Thanks,
Yannick
_______________________________________________
eclipselink-users mailing list
eclipselink-users@...
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@...
https://dev.eclipse.org/mailman/listinfo/eclipselink-users