Setting FlushMode to manual for a @NamedQuery is ignored

Description

creating namedqueries is reworked in 5.2 and it seems only the values of JPA are allowed...

Initially its set correct in org.hibernate.internal.AbstractSharedSessionContract.initQueryFromNamedDefinition(Query, NamedQueryDefinition) as there the hibernateflush mode is set.

But in org.hibernate.internal.SessionImpl.initQueryFromNamedDefinition(Query, NamedQueryDefinition) its set eventually with the JPA mode on the query in this codepart:

As end result by default hibernate actually doesn't support the annotation MANUAL anymore.
Not sure if this is what should be, if there is a work around (that I didn't find yet, except for setting it on the created query again)

If this is intentionally then at least the FlushModeType.MANUAL should be marked as deprecated...

Environment

None

Activity

Show:
Guillaume Smet
July 11, 2018, 2:04 PM

Looks like there's something fishy here.

Could you put together a test case using our test case template: https://github.com/hibernate/hibernate-test-case-templates/tree/master/orm/hibernate-orm-5 ?

That will help getting to the bottom of it.

Thanks!

Boris Vereertbrugghen
July 11, 2018, 2:19 PM

Attached test case

Yoann Rodière
July 12, 2018, 7:11 AM

I confirm there is a change of behavior between 5.1 and 5.2. The attached test case is wrong, since it expects the flush mode to be COMMIT even though the @NamedQuery annotation sets it to MANUAL. But still, the resulting flush mode is MANUAL in 5.1, AUTO in 5.2 and 5.3, so the behavior changed.

Working on a fix.

Assignee

Yoann Rodière

Reporter

Boris Vereertbrugghen

Fix versions

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

backportDecision

None

Components

Affects versions

Priority

Minor
Configure