From 4e742f99380206896465a33152dbca09f8b99eb9 Mon Sep 17 00:00:00 2001 From: Seungrae Date: Tue, 28 May 2024 22:05:16 +0900 Subject: [PATCH 1/2] Fix typo in documentation --- .../antora/modules/ROOT/pages/jpa/entity-persistence.adoc | 4 ++-- .../modules/ROOT/pages/jpa/jpd-misc-cdi-integration.adoc | 2 +- src/main/antora/modules/ROOT/pages/jpa/query-methods.adoc | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/antora/modules/ROOT/pages/jpa/entity-persistence.adoc b/src/main/antora/modules/ROOT/pages/jpa/entity-persistence.adoc index 16ad24607f..2fdf37d7a2 100644 --- a/src/main/antora/modules/ROOT/pages/jpa/entity-persistence.adoc +++ b/src/main/antora/modules/ROOT/pages/jpa/entity-persistence.adoc @@ -3,12 +3,12 @@ This section describes how to persist (save) entities with Spring Data JPA. -[[jpa.entity-persistence.saving-entites]] +[[jpa.entity-persistence.saving-entities]] == Saving Entities Saving an entity can be performed with the `CrudRepository.save(…)` method. It persists or merges the given entity by using the underlying JPA `EntityManager`. If the entity has not yet been persisted, Spring Data JPA saves the entity with a call to the `entityManager.persist(…)` method. Otherwise, it calls the `entityManager.merge(…)` method. -[[jpa.entity-persistence.saving-entites.strategies]] +[[jpa.entity-persistence.saving-entities.strategies]] === Entity State-detection Strategies Spring Data JPA offers the following strategies to detect whether an entity is new or not: diff --git a/src/main/antora/modules/ROOT/pages/jpa/jpd-misc-cdi-integration.adoc b/src/main/antora/modules/ROOT/pages/jpa/jpd-misc-cdi-integration.adoc index 98ba2bb2be..151eacb363 100644 --- a/src/main/antora/modules/ROOT/pages/jpa/jpd-misc-cdi-integration.adoc +++ b/src/main/antora/modules/ROOT/pages/jpa/jpd-misc-cdi-integration.adoc @@ -46,7 +46,7 @@ class CdiConfig { In the preceding example, the container has to be capable of creating JPA `EntityManagers` itself. All the configuration does is re-export the JPA `EntityManager` as a CDI bean. -The Spring Data JPA CDI extension picks up all available `EntityManager` instances as CDI beans and creates a proxy for a Spring Data repository whenever a bean of a repository type is requested by the container. Thus, obtaining an instance of a Spring Data repository is a matter of declaring an `@Injected` property, as shown in the following example: +The Spring Data JPA CDI extension picks up all available `EntityManager` instances as CDI beans and creates a proxy for a Spring Data repository whenever a bean of a repository type is requested by the container. Thus, obtaining an instance of a Spring Data repository is a matter of declaring an `@Inject` property, as shown in the following example: [source, java] ---- diff --git a/src/main/antora/modules/ROOT/pages/jpa/query-methods.adoc b/src/main/antora/modules/ROOT/pages/jpa/query-methods.adoc index 00e4c203e3..d6fb186acc 100644 --- a/src/main/antora/modules/ROOT/pages/jpa/query-methods.adoc +++ b/src/main/antora/modules/ROOT/pages/jpa/query-methods.adoc @@ -25,6 +25,7 @@ Generally, the query creation mechanism for JPA works as described in {spring-da .Query creation from method names ==== +[source, java] ---- public interface UserRepository extends Repository { @@ -52,7 +53,7 @@ The following table describes the keywords supported for JPA and what a method c |`After`|`findByStartDateAfter`|`… where x.startDate > ?1` |`Before`|`findByStartDateBefore`|`… where x.startDate < ?1` |`IsNull`, `Null`|`findByAge(Is)Null`|`… where x.age is null` -|`IsNotNull`, `NotNull`|`findByAge(Is)NotNull`|`… where x.age not null` +|`IsNotNull`, `NotNull`|`findByAge(Is)NotNull`|`… where x.age is not null` |`Like`|`findByFirstnameLike`|`… where x.firstname like ?1` |`NotLike`|`findByFirstnameNotLike`|`… where x.firstname not like ?1` |`StartingWith`|`findByFirstnameStartingWith`|`… where x.firstname like ?1` (parameter bound with appended `%`) @@ -76,7 +77,7 @@ For example, `select distinct u from User u` will produce a complete different r In the first case, since you are including `User.id`, nothing will duplicated, hence you'll get the whole table, and it would be of `User` objects. However, that latter query would narrow the focus to just `User.lastname` and find all unique last names for that table. -This would also yield a `List` result set instead of a `List result set. +This would also yield a `List` result set instead of a `List` result set. `countDistinctByLastname(String lastname)` can also produce unexpected results. @@ -130,7 +131,7 @@ The query has a special name that is used to resolve it at runtime. [[jpa.query-methods.named-queries.declaring-interfaces]] === Declaring Interfaces -To allow these named queries, specify the `UserRepositoryWithRewriter` as follows: +To allow these named queries, specify the `UserRepository` as follows: .Query method declaration in UserRepository ==== From 51c9cd2f93c9e1c3dc13872b3b00f8d1e7942ca8 Mon Sep 17 00:00:00 2001 From: Seungrae Date: Tue, 28 May 2024 22:05:49 +0900 Subject: [PATCH 2/2] Fix broken links in documentation --- .../modules/ROOT/pages/jpa/misc-merging-persistence-units.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/antora/modules/ROOT/pages/jpa/misc-merging-persistence-units.adoc b/src/main/antora/modules/ROOT/pages/jpa/misc-merging-persistence-units.adoc index 35ef016c2f..7b2165b665 100644 --- a/src/main/antora/modules/ROOT/pages/jpa/misc-merging-persistence-units.adoc +++ b/src/main/antora/modules/ROOT/pages/jpa/misc-merging-persistence-units.adoc @@ -37,5 +37,5 @@ A plain JPA setup requires all annotation-mapped entity classes to be listed in ---- ==== -NOTE: As of Spring 3.1, a package to scan can be configured on the `LocalContainerEntityManagerFactoryBean` directly to enable classpath scanning for entity classes. See the link:{springJavadocUrl}org/springframework/orm/jpa/LocalContainerEntityManagerFactoryBean.html#setPackagesToScan(java.lang.String...)$$[JavaDoc] for details. +NOTE: As of Spring 3.1, a package to scan can be configured on the `LocalContainerEntityManagerFactoryBean` directly to enable classpath scanning for entity classes. See the link:{springJavadocUrl}/org/springframework/orm/jpa/LocalContainerEntityManagerFactoryBean.html#setPackagesToScan(java.lang.String...)$$[JavaDoc] for details.