« Return to Thread: Re: one connection for each request

Re: Re: one connection for each request

by ymajoros :: Rate this Message:

Reply to Author | View in Thread

Christopher.Mathrusse@... a écrit :

>
> 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.
>
 Ok, I think I understand your point. So, it seems everything is ok and
I don't need to worry, right? Is there a way to "see" the effective
transaction boundaries? I mean, can I find out which requests where
executed in what transaction?

 I thought that for an ejb-managed EntityManager, there was a client
session, and so the EntityManager should keep its connection while it is
alive. Is this wrong?

 Thanks for your advice,

Yannick
_______________________________________________
eclipselink-users mailing list
eclipselink-users@...
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

 « Return to Thread: Re: one connection for each request