Interface MutationOrSelectionQuery

All Superinterfaces:
CommonQueryContract, Query, Query<Object>, StatementOrTypedQuery

@Incubating public interface MutationOrSelectionQuery extends StatementOrTypedQuery, Query<Object>
Unifies StatementOrTypedQuery with Query, allowing backward compatibility with older versions of Hibernate and JPA which did not carefully distinguish selection queries from insert, update, and delete mutation statements.

An instance of this interface is returned by SharedSessionContract.createQuery(String) or SharedSessionContract.createNamedQuery(String). But in newly written code, this interface should not be used to directly execute a query or statement. Instead:

A typical idiom is the following:

List<Book> matchingBooks =
        session.createQuery("from Book where title like :titlePattern")
                .ofType(Book.class)
                .setParameter("titlePattern", pattern)
                .setMaxResults(pageSize)
                .setCacheStoreMode(CacheStoreMode.BYPASS)
                .getResultList();
Since:
8.0
See Also: