[hibernate-dev] Native query and auto-flush

Steve Ebersole steve at hibernate.org
Thu Oct 30 09:56:03 EDT 2014

Personally having entities dirtied as part of a read-only
transaction sounds like an application bug to me.  We could try to detect a
read-only transaction state (not sure how we'd do that across all cases)
and circumvent the flush there, but that would add unnecessary overhead to
applications that do the right thing.

On Thu, Oct 30, 2014 at 8:44 AM, Guillaume Smet <guillaume.smet at gmail.com>

> Hi!
> Starting with HHH-8487, when we execute a native query, an auto-flush
> is executed (and might be limited with addSynchronizedEntityClass and
> allegates).
> While I understand the rationale of this change, we are having a few
> issues with this when the transaction opened is read-only which is the
> case for all our read-only queries: Hibernate tries to flush the dirty
> entities in a read-only transaction and fails.
> The heart of the issue here is that we have dirty entities which
> shouldn't be dirty (see my post on embedded and dirtiness) but I'm
> wondering if it's a behavior which was missed by this patch or
> something intentional. So I thought I might as well report it.
> --
> Guillaume
> _______________________________________________
> 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