diff --git a/src/main/asciidoc/faq.adoc b/src/main/asciidoc/faq.adoc index 31c5c8e04..fd310d610 100644 --- a/src/main/asciidoc/faq.adoc +++ b/src/main/asciidoc/faq.adoc @@ -43,3 +43,4 @@ Currently I have implemented a repository layer based on `HibernateDaoSupport`. [qanda] I want to use Spring Data JPA auditing capabilities but have my database already set up to set modification and creation date on entities. How to prevent Spring Data from setting the date programmatically.:: Just use the `set-dates` attribute of the `auditing` namespace element to false. + diff --git a/src/main/asciidoc/glossary.adoc b/src/main/asciidoc/glossary.adoc index 168439a00..fc1196dcd 100644 --- a/src/main/asciidoc/glossary.adoc +++ b/src/main/asciidoc/glossary.adoc @@ -28,3 +28,4 @@ JPA:: Spring:: Java application framework - link:$$http://projects.spring.io/spring-framework$$[http://projects.spring.io/spring-framework] + diff --git a/src/main/asciidoc/index.adoc b/src/main/asciidoc/index.adoc index 29420f6da..970c28b17 100644 --- a/src/main/asciidoc/index.adoc +++ b/src/main/asciidoc/index.adoc @@ -1,28 +1,38 @@ = Spring Data JPA - Reference Documentation Oliver Gierke; Thomas Darimont; Christoph Strobl -{version} +:revnumber: {version} +:revdate: {localdate} :toc: +:toc-placement!: :spring-data-commons-docs: https://raw.githubusercontent.com/spring-projects/spring-data-commons/master/src/main/asciidoc :spring-framework-docs: http://docs.spring.io/spring-framework/docs/current/spring-framework-reference/html +(C) 2008-2014 The original authors. + NOTE: Copies of this document may be made for your own use and for distribution to others, provided that you do not charge any fee for such copies and further provided that each copy contains this Copyright Notice, whether distributed in print or electronically. +toc::[] + include::preface.adoc[] +:leveloffset: +1 +include::{spring-data-commons-docs}/repositories.adoc[] +:leveloffset: -1 [[reference]] = Reference Documentation -:leveloffset: 1 -include::{spring-data-commons-docs}/repositories.adoc[] + +:leveloffset: +1 include::jpa.adoc[] -:leveloffset: 0 +:leveloffset: -1 [[appendix]] = Appendix + :numbered!: -:leveloffset: 1 +:leveloffset: +1 include::{spring-data-commons-docs}/repository-namespace-reference.adoc[] include::{spring-data-commons-docs}/repository-populator-namespace-reference.adoc[] include::{spring-data-commons-docs}/repository-query-keywords-reference.adoc[] include::faq.adoc[] include::glossary.adoc[] -:leveloffset: 0 +:leveloffset: -1 diff --git a/src/main/asciidoc/jpa.adoc b/src/main/asciidoc/jpa.adoc index 2258eaeac..534a358b6 100644 --- a/src/main/asciidoc/jpa.adoc +++ b/src/main/asciidoc/jpa.adoc @@ -1,7 +1,7 @@ [[jpa.repositories]] = JPA Repositories -This chapter includes details of the JPA repository implementation. +This chapter will point out the specialties for repository support for JPA. This builds on the core repository support explained in <>. So make sure you've got a sound understanding of the basic concepts explained there. [[jpa.introduction]] == Introduction @@ -36,7 +36,7 @@ Using this element looks up Spring Data repositories as described in <> for more information) or rather annotate your query method with @Query (see <> for details). +Although getting a query derived from the method name is quite convenient, one might face the situation in which either the method name parser does not support the keyword one wants to use or the method name would get unnecessarily ugly. So you can either use JPA named queries through a naming convention (see <> for more information) or rather annotate your query method with `@Query` (see <> for details). [[jpa.query-methods.query-creation]] === Query creation @@ -139,7 +139,7 @@ We will create a query using the JPA criteria API from this but essentially this ==== .Supported keywords inside method names -[options="header", cols="1,1,2"] +[options = "header, autowidth"] |=============== |Keyword|Sample|JPQL snippet |`And`|`findByLastnameAndFirstname`|`… where x.lastname = ?1 and x.firstname = ?2` @@ -251,7 +251,7 @@ public interface UserRepository extends JpaRepository { Using advanced `LIKE` expressionsThe query execution mechanism for manually defined queries using @Query allow the definition of advanced `LIKE` expressions inside the query definition. -.Advanced `LIKE` expressions in @Query +.Advanced like-expressions in @Query ==== [source, java] ---- @@ -273,7 +273,7 @@ Native queriesThe `@Query` annotation allows to execute native queries by settin ---- public interface UserRepository extends JpaRepository { - @Query(value = "SELECT * FROM USERS WHERE EMAIL`ADDRESS = ?0", nativeQuery = true) + @Query(value = "SELECT * FROM USERS WHERE EMAIL_ADDRESS = ?0", nativeQuery = true) User findByEmailAddress(String emailAddress); } ---- @@ -296,8 +296,8 @@ public interface UserRepository extends JpaRepository { @Param("firstname") String firstname); } ---- -Note that the method parameters are switched according to the occurrence in the query defined. ==== +Note that the method parameters are switched according to the occurrence in the query defined. [[jpa.query.spel-expressions]] === Using SpEL expressions @@ -305,13 +305,13 @@ Note that the method parameters are switched according to the occurrence in the As of Spring Data JPA release 1.4 we support the usage of restricted SpEL template expressions in manually defined queries via `@Query`. Upon query execution these expressions are evaluated against a predefined set of variables. We support the following list of variables to be used in a manual query. .Supported variables inside SpEL based query templates -[options="header", cols="1,3"] +[options="header, autowidth"] |=============== |Variable|Usage|Description |`entityName`|`select x from #{#entityName} x`|Inserts the `entityName` of the domain type associated with the given Repository. The `entityName` is resolved as follows: If the domain type has set the name property on the `@Entity` annotation then it will be used. Otherwise the simple class-name of the domain type will be used. |=============== -The following example demonstrates one use case for the `#{#entityName}` expression in a query string where you want to define a repository interface with a query method with a manually defined query. In order not to have to state the actual entity name in the query string of a `@Query` annotation one can use the `#{#entityName}` Variable. +The following example demonstrates one use case for the `+#{#entityName}+` expression in a query string where you want to define a repository interface with a query method with a manually defined query. In order not to have to state the actual entity name in the query string of a `@Query` annotation one can use the `+#{#entityName}+` Variable. [NOTE] ==== @@ -405,8 +405,8 @@ public interface UserRepository extends Repository { Page findByLastname(String lastname, Pageable pageable); } ---- -The just shown declaration would apply the configured `@QueryHint` for that actually query but omit applying it to the count query triggered to calculate the total number of pages. ==== +The just shown declaration would apply the configured `@QueryHint` for that actually query but omit applying it to the count query triggered to calculate the total number of pages. [[jpa.entity-graph]] === Configuring Fetch- and LoadGraphs @@ -716,9 +716,9 @@ interface UserRepository extends Repository { ---- ==== -:leveloffset: 2 +:leveloffset: +1 include::{spring-data-commons-docs}/auditing.adoc[] -:leveloffset: 0 +:leveloffset: -1 [[jpa.auditing]] == JPA Auditing @@ -883,3 +883,4 @@ class RepositoryClient { } } ---- + diff --git a/src/main/asciidoc/preface.adoc b/src/main/asciidoc/preface.adoc index 3a27a4ef7..fea7f602d 100644 --- a/src/main/asciidoc/preface.adoc +++ b/src/main/asciidoc/preface.adoc @@ -1,13 +1,13 @@ [[preface]] -[preface] = Preface [[project]] +[preface] == Project metadata -[options="compact"] -- Version control - link:$$git://github.com/spring-projects/spring-data-jpa.git$$[git://github.com/spring-projects/spring-data-jpa.git] -- Bugtracker - link:$$https://jira.springsource.org/browse/DATAJPA$$[https://jira.springsource.org/browse/DATAJPA] -- Release repository - link:$$http://repo.spring.io/libs-release$$[http://repo.spring.io/libs-release] -- Milestone repository - link:$$http://repo.spring.io/libs-milestone$$[http://repo.spring.io/libs-milestone] -- Snapshot repository - link:$$http://repo.spring.io/libs-snapshot$$[http://repo.spring.io/libs-snapshot] +* Version control - http://github.com/spring-projects/spring-data-jpa +* Bugtracker - https://jira.spring.io/browse/DATAJPA +* Release repository - https://repo.spring.io/libs-release +* Milestone repository - https://repo.spring.io/libs-milestone +* Snapshot repository - https://repo.spring.io/libs-snapshot +