[hibernate-dev] AvailableSettings.DISCARD_PC_ON_CLOSE and Transaction status

Vlad Mihalcea mihalcea.vlad at gmail.com
Wed Sep 21 09:55:50 EDT 2016

Check out this Jira issue that I integrated today:


If we enable this property, all the underlying resources are released right
Otherwise (the default option), resources are released when the transaction
is ended (commit/rollback).

If this fix was a mistake and we should not support this property, then we
should deprecate it and remove it in a future release, right?


On Wed, Sep 21, 2016 at 4:48 PM, Steve Ebersole <steve at hibernate.org> wrote:

> I have no idea what "I could make use of it" means in this context.  Make
> use of what?  That setting?  That setting has zero effect today, unless I
> missed something.
> On Wed, Sep 21, 2016 at 8:33 AM Vlad Mihalcea <mihalcea.vlad at gmail.com>
> wrote:
>> I could make use of it in a non-JTA environment. I guess we need to think
>> what should we do with the transaction status because now it's still
>> active, but if we try to rollback, we'll get an exception because the
>> connection was closed.
>> Vlad
>> On Wed, Sep 21, 2016 at 4:30 PM, Steve Ebersole <steve at hibernate.org>
>> wrote:
>>> Sorry, *was* only valid for JTA.  As you mentioned we handle this
>>> differently today.
>>> On Wed, Sep 21, 2016 at 8:29 AM Steve Ebersole <steve at hibernate.org>
>>> wrote:
>>>> DISCARD_PC_ON_CLOSE, as a concept, is only valid for JTA iirc.
>>>> On Wed, Sep 21, 2016 at 8:11 AM Vlad Mihalcea <mihalcea.vlad at gmail.com>
>>>> wrote:
>>>>> Hi,
>>>>> While reviewing and adding a test case for
>>>>> https://hibernate.atlassian.net/browse/HHH-11120,
>>>>> I realized that if we enable the AvailableSettings.DISCARD_PC_ON_CLOSE
>>>>> property,
>>>>> the database connection gets closed when the EntityManager is closed,
>>>>> while
>>>>> the EntityTransaction status remains ACTIVE.
>>>>> I noticed that in the call:
>>>>> currentHibernateTransaction.invalidate();
>>>>> But this method is no-op and deprecated as well.
>>>>> Is this behavior intended? If the database connection was closed, at
>>>>> least
>>>>> for RESOURCE_LOCAL, on most RDBMS engines, the underlying transaction
>>>>> gets
>>>>> rolled back as well.
>>>>> For JTA, the connection might still be open and allocated to the
>>>>> current
>>>>> user since the TM controls when the resources are to be released.
>>>>> Should we leave this behavior like that?
>>>>> Vlad
>>>>> _______________________________________________
>>>>> hibernate-dev mailing list
>>>>> hibernate-dev at lists.jboss.org
>>>>> https://lists.jboss.org/mailman/listinfo/hibernate-dev

More information about the hibernate-dev mailing list