That is debatable. But in any case, this is not a bug. This is not documented to work this way for Hibernate's native sql queries. Hibernate's native query API already has a means (mentioned in
HHH-8487
) for controlling flush by adding "synchronized spaces".
HHH-8487
adds what you mention, but just for JPA native queries mainly because JPA does not define any such concept.
session.createSQLQuery("select id from product").uniqueResult()
becomes
session.createSQLQuery("select id from product").addSynchronizedEntityClass(Product.class).uniqueResult()
I'm ok with leaving this open though to see if this improvement requests gets enough votes.
|