From 8fd965d4a384bc869d25ab6d451c5a30be2069ef Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Mon, 23 Jul 2012 19:32:52 +0200 Subject: [PATCH] DATAJPA-227 - Improved documentation on native queries with @Query. --- src/docbkx/reference/jpa.xml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/docbkx/reference/jpa.xml b/src/docbkx/reference/jpa.xml index bbfb65264..7eee95757 100644 --- a/src/docbkx/reference/jpa.xml +++ b/src/docbkx/reference/jpa.xml @@ -438,7 +438,8 @@ public class User { in orm.xml. - Declare query at the query method using @Query + Declare query at the query method using + <interfacename>@Query</interfacename> public interface UserRepository extends JpaRepository<User, Long> { @@ -456,6 +457,17 @@ public class User { dynamic sorting for native queries as we'd have to manipulate the actual query declared and we cannot do this reliably for native SQL. + + + Declare a native query at the query method using + <interfacename>@Query</interfacename> + + public interface UserRepository extends JpaRepository<User, Long> { + + @Query(value = "SELECT FROM USERS WHERE EMAIL_ADDRESS = ?0", nativeQuery = true) + User findByEmailAddress(String emailAddress); +} + @@ -570,7 +582,7 @@ int setFixedFirstnameFor(String firstname, String lastname); Specifications in a variety of ways. For example, the readAll method will return all - entities that match the specification: + entities that match the specification: List<T> readAll(Specification<T> spec);