users@glassfish.java.net

[gf-users] Re: Glassfish JDBC Connection Pool property question

From: Reza Rahman <Reza.Rahman_at_oracle.com>
Date: Fri, 11 Jul 2014 17:55:44 -0400

Honestly I am having a hard time following what the problem is. Can you
kindly outline the specific case you believe to be a bug?

If it helps, let me try to explain the entity manager behavior again:

* If it is a non-read operation, the entity manager in your case will
expect a transaction. It should throw an exception otherwise.
* If it's a read operation the entity manager won't care if there is a
transaction or not.

I would advise reading the JPA spec for further details.

Either way, the non-transactional setting will probably work fine. A
non-transactional JNDI bound data source connection will likely just
ignore a transaction even if one is present.

Just out of curiosity, is this mostly a learning exercise or is there a
real world use case you are trying to solve (doesn't matter either way,
I'll try to help you within reason)?

On 7/11/2014 5:39 PM, Noah White wrote:
>
> On Jul 11, 2014, at 5:27 PM, Reza Rahman <Reza.Rahman_at_oracle.com
> <mailto:Reza.Rahman_at_oracle.com>> wrote:
>
>> Responses in-line:
>>
>> On 7/11/2014 5:10 PM, Noah White wrote:
>>> Hi Reza:
>>>
>>> So I have some EJBs which are annotated with
>>> @TransactionAttribute(TransactionAttribute.NOT_SUPPORTED) , they
>>> make read-only calls to the DB, and they run without throwing any
>>> exceptions whether or not this box is checked off so my question is
>>> basically two fold:
>>>
>>> 1. Whats the purpose of this setting? (The User’s Guide doesn’t give
>>> anymore detail then the GUI does)
>>
>> It is basically saying that the connection will not participate in a
>> transaction (likely either JTA or local).
>>
>>> 2. What are the expectations in this case? (So I can determine if
>>> this is expected or a bug)
>>
>> That really depends on the entity manager you are using. Assuming you
>> are using a transaction scoped managed JPA object it will allow you
>> to do read operations without a transaction and throw an exception
>> otherwise.
>
> Yes, I’m using EJB 3.1 CMT and the PC associated with the injected EM
> is a JTA resource using this connection pool.
>
> My confusion around this setting comes from the fact that I have EJB
> methods that start TXs and I have EJB methods which explicitly do not
> w/NOT_SUPPORTED.
>
> Whether or not this box is checked off, my code (both the TX EJB
> methods and the ones marked NOT_SUPPORTED) will run w/out throwing an
> exception. I would have thought that if the check box is *not*
> checked, in the case where I have an EJB method annotated with
> NOT_SUPPORTED, the underlying connection would still be in a TX (which
> would violate the EJB annotations contract) or an exception would be
> thrown. I don’t see an exception.
>
> -Noah