Skip to content

Commit f0c9a99

Browse files
committed
Refactor the JpaPagingItemReader by making the entityManagerFactory field final.
Signed-off-by: Tahitoa MERLIN <[email protected]>
1 parent a2b880f commit f0c9a99

File tree

2 files changed

+1
-6
lines changed

2 files changed

+1
-6
lines changed

spring-batch-infrastructure/src/main/java/org/springframework/batch/infrastructure/item/database/JpaPagingItemReader.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
*/
8888
public class JpaPagingItemReader<T> extends AbstractPagingItemReader<T> {
8989

90-
private EntityManagerFactory entityManagerFactory;
90+
private final EntityManagerFactory entityManagerFactory;
9191

9292
private @Nullable EntityManager entityManager;
9393

@@ -113,10 +113,6 @@ public JpaPagingItemReader(EntityManagerFactory entityManagerFactory) {
113113
this.entityManagerFactory = entityManagerFactory;
114114
}
115115

116-
public void setEntityManagerFactory(EntityManagerFactory entityManagerFactory) {
117-
this.entityManagerFactory = entityManagerFactory;
118-
}
119-
120116
/**
121117
* The parameter values to be used for the query execution.
122118
* @param parameterValues the values keyed by the parameter named used in the query

spring-batch-infrastructure/src/test/java/org/springframework/batch/infrastructure/item/database/JpaPagingItemReaderNamedQueryIntegrationTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ protected AbstractPagingItemReader<Foo> getItemReader() throws Exception {
4747
jpaNamedQueryProvider.setEntityClass(Foo.class);
4848
jpaNamedQueryProvider.afterPropertiesSet();
4949

50-
reader.setEntityManagerFactory(entityManagerFactory);
5150
reader.setQueryProvider(jpaNamedQueryProvider);
5251
reader.afterPropertiesSet();
5352
reader.setSaveState(true);

0 commit comments

Comments
 (0)