Hi. But why is there any local transaction? I haven't started any, I just set autoCommit to false, but never call begin().
I am using GlassFish 3, I don't know what they do on reclaiming the connection, and I read that it is implementation specific in what happens on close() when a tx is not committed. I will research further.
My jdbc foo is apparently lacking, as I get exactly the same results for PostgreSQL 9.1...


On Mon, Feb 18, 2013 at 3:54 PM, Kristian Waagan <kristian.waagan@oracle.com> wrote:
On 18.02.2013 15:15,  Wujek Srujek wrote:
What I don't understand:
1. how is it possible that the insertion is visible in the next select? there is no transaction, autoCommit is explicitly set to false, there is no caching like EntityManager cache - or is there?

Hello,

Because you're in the same local transaction and you haven't yet rolled back what you have done so far?


2. how is it possible that the insertion is made persistent after the code executes, without the transaction ever being committed (either local or global) - I can see in a db viewer that the row has been added? the close() in finally seems to be doing magic things


That I do not know (I've only looked at the code in your email).
You could try to enable client side tracing on the Derby network driver to see what's going on [1]. Could it be that your application server / container is issuing a commit when it reclaims the connection?

I have not verified that Derby doesn't do the above for XA, but normally Derby throws an exception if close is called and there is an active transaction.


--
Kristian

[1] See https://builds.apache.org/job/Derby-docs/lastSuccessfulBuild/artifact/trunk/out/adminguide/cadminappsclienttracing.html . The simpler server side tracing may also be to some help: derby.language.logStatementText=true