[hibernate-dev] Native-SQL queries and flushing

Steve Ebersole steve at hibernate.org
Wed Sep 11 09:37:13 EDT 2013


I never heard alternatives, so this is now implemented as described 
below.

https://hibernate.atlassian.net/browse/HHH-8487


On Tue 10 Sep 2013 12:05:35 AM CDT, Steve Ebersole wrote:
> We will need to make a slight change to execution of native SQL
> queries in order to pass the JPA 2.1 TCK.  The new TCK tests that
> execution of a native SQL query does an "auto flush".
>
> The problem with this is that, unlike with HQL/JPQL, we do not know
> the tables affected by a native SQL query (and doing so would be
> extremely difficult and not worth the effort).  Historically,
> Hibernate users would have relied on the
> addSynchronizedQuerySpace/addSynchronizedEntityName methods of
> org.hibernate.SQLQuery to indicate the tables needing flushed.  JPA
> however has no such notion.
>
> As I see it, I think the change here needs to be to implicitly perform
> a *full flush* when a JPA native SQL query is executed where the
> wrapped/underlying org.hibernate.SQLQuery does not define any "query
> spaces"; a partial flush just is not possible in that case. That
> allows us to pass the TCK, but still allows users to set "query
> spaces" if they wish to do the more efficient partial auto-flush.
>
> Any alternate suggestions?


More information about the hibernate-dev mailing list