Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Re: one connection for each request


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@xxxxxxxxxx
Sybase, Inc



Yannick Majoros <yannick.majoros@xxxxxxxxxxxx>
Sent by: eclipselink-users-bounces@xxxxxxxxxxx

06/26/2009 08:58 AM

Please respond to
EclipseLink User Discussions <eclipselink-users@xxxxxxxxxxx>

To
EclipseLink User Discussions <eclipselink-users@xxxxxxxxxxx>
cc
Subject
Re: [eclipselink-users] Re: one connection for each request





Christopher.Mathrusse@xxxxxxxxxx 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@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users



Back to the top