Skip to content

Commit 6ed0f8c

Browse files
committed
Improve docs on transactionality of methods declared on repository interfaces.
We're now more specific on what CRUD methods means in the context of transactional query methods. Also, we now mention default methods explicitly in the discussion of query methods. Fixes #2868.
1 parent 1d69ece commit 6ed0f8c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Diff for: src/main/asciidoc/jpa.adoc

+3-2
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ include::query-by-example.adoc[leveloffset=+1]
11201120
[[transactions]]
11211121
== Transactionality
11221122

1123-
By default, CRUD methods on repository instances inherited from link:$$https://docs.spring.io/spring-data/data-jpa/docs/current/api/org/springframework/data/jpa/repository/support/SimpleJpaRepository.html$$[`SimpleJpaRepository`] are transactional.
1123+
By default, methods inherited from `CrudRepository` inherited the transactional configuration from from link:$$https://docs.spring.io/spring-data/data-jpa/docs/current/api/org/springframework/data/jpa/repository/support/SimpleJpaRepository.html$$[`SimpleJpaRepository`].
11241124
For read operations, the transaction configuration `readOnly` flag is set to `true`.
11251125
All others are configured with a plain `@Transactional` so that default transaction configuration applies.
11261126
Repository methods that are backed by transactional repository fragments inherit the transactional attributes from the actual fragment method.
@@ -1182,7 +1182,8 @@ Note that the call to `save` is not strictly necessary from a JPA point of view,
11821182
[[transactional-query-methods]]
11831183
=== Transactional query methods
11841184

1185-
To let your query methods be transactional, use `@Transactional` at the repository interface you define, as shown in the following example:
1185+
Declared query methods (including default methods) do not get any transaction configuration applied by default.
1186+
To run those methods transactionally, use `@Transactional` at the repository interface you define, as shown in the following example:
11861187

11871188
.Using @Transactional at query methods
11881189
====

0 commit comments

Comments
 (0)