Uploaded image for project: 'Hibernate ORM'
  1. HHH-12795

Setting FlushMode to manual for a @NamedQuery is ignored

    Details

      Description

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

      @NamedQuery(readOnly=true, flushMode=FlushModeType.MANUAL, name="XXX",
                  query = "select id from YYY"),
      

      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:

      		if ( namedQueryDefinition.getFlushMode() != null ) {
      			if ( namedQueryDefinition.getFlushMode() == FlushMode.COMMIT ) {
      				query.setFlushMode( FlushModeType.COMMIT );
      			}
      			else {
      				query.setFlushMode( FlushModeType.AUTO );
      			}
      		}
      

      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...

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: