Skip to content

Fix typo in documentation #3489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Contributor Author

@Seungpang Seungpang May 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

스크린샷 2024-05-28 오후 10 25 00

The link is broken because it should be javadoc-api/org instead of javadoc-apiorg.


7 changes: 4 additions & 3 deletions src/main/antora/modules/ROOT/pages/jpa/query-methods.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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<User, Long> {

Expand Down Expand Up @@ -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 `%`)
Expand All @@ -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<String>` result set instead of a `List<User`> result set.
This would also yield a `List<String>` result set instead of a `List<User>` result set.


`countDistinctByLastname(String lastname)` can also produce unexpected results.
Expand Down Expand Up @@ -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
====
Expand Down
Loading