Skip to content

Commit 064cd3b

Browse files
committed
Merge branch '6.0.x'
# Conflicts: # gradle.properties # spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java
2 parents 6957ac5 + 75f5dac commit 064cd3b

File tree

5 files changed

+26
-34
lines changed

5 files changed

+26
-34
lines changed

framework-docs/modules/ROOT/pages/data-access/orm/jpa.adoc

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -281,17 +281,17 @@ Spring Data JPA, make sure to set up deferred bootstrapping for its repositories
281281
[[orm-jpa-dao]]
282282
== Implementing DAOs Based on JPA: `EntityManagerFactory` and `EntityManager`
283283

284-
NOTE: Although `EntityManagerFactory` instances are thread-safe, `EntityManager` instances are
285-
not. The injected JPA `EntityManager` behaves like an `EntityManager` fetched from an
284+
NOTE: Although `EntityManagerFactory` instances are thread-safe, `EntityManager` instances
285+
are not. The injected JPA `EntityManager` behaves like an `EntityManager` fetched from an
286286
application server's JNDI environment, as defined by the JPA specification. It delegates
287287
all calls to the current transactional `EntityManager`, if any. Otherwise, it falls back
288288
to a newly created `EntityManager` per operation, in effect making its usage thread-safe.
289289

290290
It is possible to write code against the plain JPA without any Spring dependencies, by
291291
using an injected `EntityManagerFactory` or `EntityManager`. Spring can understand the
292292
`@PersistenceUnit` and `@PersistenceContext` annotations both at the field and the method level
293-
if a `PersistenceAnnotationBeanPostProcessor` is enabled. The following example shows a plain JPA DAO implementation
294-
that uses the `@PersistenceUnit` annotation:
293+
if a `PersistenceAnnotationBeanPostProcessor` is enabled. The following example shows a plain
294+
JPA DAO implementation that uses the `@PersistenceUnit` annotation:
295295

296296
[tabs]
297297
======
@@ -384,9 +384,9 @@ Consider the following example:
384384
----
385385

386386
The main problem with such a DAO is that it always creates a new `EntityManager` through
387-
the factory. You can avoid this by requesting a transactional `EntityManager` (also
388-
called a "`shared EntityManager`" because it is a shared, thread-safe proxy for the actual
389-
transactional EntityManager) to be injected instead of the factory. The following example shows how to do so:
387+
the factory. You can avoid this by requesting a transactional `EntityManager` (also called a
388+
"`shared EntityManager`" because it is a shared, thread-safe proxy for the actual transactional
389+
EntityManager) to be injected instead of the factory. The following example shows how to do so:
390390

391391
[tabs]
392392
======
@@ -430,19 +430,19 @@ The `@PersistenceContext` annotation has an optional attribute called `type`, wh
430430
`EntityManager` proxy. The alternative, `PersistenceContextType.EXTENDED`, is a completely
431431
different affair. This results in a so-called extended `EntityManager`, which is not
432432
thread-safe and, hence, must not be used in a concurrently accessed component, such as a
433-
Spring-managed singleton bean. Extended `EntityManager` instances are only supposed to be used in
434-
stateful components that, for example, reside in a session, with the lifecycle of the
433+
Spring-managed singleton bean. Extended `EntityManager` instances are only supposed to be used#
434+
in stateful components that, for example, reside in a session, with the lifecycle of the
435435
`EntityManager` not tied to a current transaction but rather being completely up to the
436436
application.
437437

438438
.Method- and field-level Injection
439439
****
440440
You can apply annotations that indicate dependency injections (such as `@PersistenceUnit` and
441-
`@PersistenceContext`) on field or methods inside a class -- hence the
442-
expressions "`method-level injection`" and "`field-level injection`". Field-level
443-
annotations are concise and easier to use while method-level annotations allow for further
444-
processing of the injected dependency. In both cases, the member visibility (public,
445-
protected, or private) does not matter.
441+
`@PersistenceContext`) on field or methods inside a class -- hence the expressions
442+
"`method-level injection`" and "`field-level injection`". Field-level annotations are
443+
concise and easier to use while method-level annotations allow for further processing of the
444+
injected dependency. In both cases, the member visibility (public, protected, or private)
445+
does not matter.
446446
447447
What about class-level annotations?
448448
@@ -451,9 +451,9 @@ injection.
451451
****
452452

453453
The injected `EntityManager` is Spring-managed (aware of the ongoing transaction).
454-
Even though the new DAO implementation uses method-level
455-
injection of an `EntityManager` instead of an `EntityManagerFactory`, no change is
456-
required in the application context XML, due to annotation usage.
454+
Even though the new DAO implementation uses method-level injection of an `EntityManager`
455+
instead of an `EntityManagerFactory`, no change is required in the bean definition
456+
due to annotation usage.
457457

458458
The main advantage of this DAO style is that it depends only on the Java Persistence API.
459459
No import of any Spring class is required. Moreover, as the JPA annotations are understood,

spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ void convertCollectionToCollection() throws Exception {
660660
foo.add("2");
661661
foo.add("3");
662662
@SuppressWarnings("unchecked")
663-
List<Integer> bar = (List<Integer>) conversionService.convert(foo, TypeDescriptor.forObject(foo),
663+
List<Integer> bar = (List<Integer>) conversionService.convert(foo,
664664
new TypeDescriptor(getClass().getField("genericList")));
665665
assertThat(bar).containsExactly(1, 2, 3);
666666
}

spring-core/src/test/java/org/springframework/core/convert/support/CollectionToCollectionConverterTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ private void testCollectionConversionToArrayList(Collection<String> aSource) {
193193
@Test
194194
void listToCollectionNoCopyRequired() throws NoSuchFieldException {
195195
List<?> input = new ArrayList<>(Arrays.asList("foo", "bar"));
196-
assertThat(conversionService.convert(input, TypeDescriptor.forObject(input),
196+
assertThat(conversionService.convert(input,
197197
new TypeDescriptor(getClass().getField("wildcardCollection")))).isSameAs(input);
198198
}
199199

@@ -253,7 +253,7 @@ void stringToEnumSet() throws Exception {
253253
List<String> list = new ArrayList<>();
254254
list.add("A");
255255
list.add("C");
256-
assertThat(conversionService.convert(list, TypeDescriptor.forObject(list), new TypeDescriptor(getClass().getField("enumSet")))).isEqualTo(EnumSet.of(MyEnum.A, MyEnum.C));
256+
assertThat(conversionService.convert(list, new TypeDescriptor(getClass().getField("enumSet")))).isEqualTo(EnumSet.of(MyEnum.A, MyEnum.C));
257257
}
258258

259259

spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ void stringToIntegerArray() {
302302
void wildcardMap() throws Exception {
303303
Map<String, String> input = new LinkedHashMap<>();
304304
input.put("key", "value");
305-
Object converted = conversionService.convert(input, TypeDescriptor.forObject(input), new TypeDescriptor(getClass().getField("wildcardMap")));
305+
Object converted = conversionService.convert(input, new TypeDescriptor(getClass().getField("wildcardMap")));
306306
assertThat(converted).isEqualTo(input);
307307
}
308308

spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,7 @@ public void execute(final String sql) throws DataAccessException {
417417
logger.debug("Executing SQL statement [" + sql + "]");
418418
}
419419

420-
/**
421-
* Callback to execute the statement.
422-
*/
420+
// Callback to execute the statement.
423421
class ExecuteStatementCallback implements StatementCallback<Object>, SqlProvider {
424422
@Override
425423
@Nullable
@@ -445,9 +443,7 @@ public <T> T query(final String sql, final ResultSetExtractor<T> rse) throws Dat
445443
logger.debug("Executing SQL query [" + sql + "]");
446444
}
447445

448-
/**
449-
* Callback to execute the query.
450-
*/
446+
// Callback to execute the query.
451447
class QueryStatementCallback implements StatementCallback<T>, SqlProvider {
452448
@Override
453449
@Nullable
@@ -542,9 +538,7 @@ public int update(final String sql) throws DataAccessException {
542538
logger.debug("Executing SQL update [" + sql + "]");
543539
}
544540

545-
/**
546-
* Callback to execute the update statement.
547-
*/
541+
// Callback to execute the update statement.
548542
class UpdateStatementCallback implements StatementCallback<Integer>, SqlProvider {
549543
@Override
550544
public Integer doInStatement(Statement stmt) throws SQLException {
@@ -570,9 +564,7 @@ public int[] batchUpdate(final String... sql) throws DataAccessException {
570564
logger.debug("Executing SQL batch update of " + sql.length + " statements");
571565
}
572566

573-
/**
574-
* Callback to execute the batch update.
575-
*/
567+
// Callback to execute the batch update.
576568
class BatchUpdateStatementCallback implements StatementCallback<int[]>, SqlProvider {
577569

578570
@Nullable
@@ -1373,7 +1365,7 @@ protected Map<String, Object> extractOutputParameters(CallableStatement cs, List
13731365
}
13741366
}
13751367
}
1376-
if (!(param.isResultsParameter())) {
1368+
if (!param.isResultsParameter()) {
13771369
sqlColIndex++;
13781370
}
13791371
}

0 commit comments

Comments
 (0)