Annotation Interface NativeQuery


Annotation to declare native queries directly on repository query methods.

Specifically @NativeQuery is a composed annotation that acts as a shortcut for @Query(nativeQuery = true) for most attributes.

This annotation defines sqlResultSetMapping to apply JPA SQL ResultSet mapping for native queries. Make sure to use the corresponding return type as defined in @SqlResultSetMapping. When using named native queries, define SQL result set mapping through @NamedNativeQuery(resultSetMapping=…) as named queries do not accept sqlResultSetMapping.

Since:
3.4
Author:
Danny van den Elshout, Mark Paluch
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Returns the name of the NamedQuery to be used to execute count queries when pagination is used.
    Defines the projection part of the count query that is generated for pagination.
    Defines a special count query that shall be used for pagination queries to look up the total number of elements for a page.
    The named query to be used.
    Class<? extends QueryRewriter>
    Define a QueryRewriter that should be applied to the query string after the query is fully assembled.
    Name of the @SqlResultSetMapping(name) to apply for this query.
    Defines the native query to be executed when the annotated method is called.