Skip to content

Refactor JpaPagingItemReader to be compliant with the requirements of constructor #5101

@maequise

Description

@maequise

As the new signature of the JpaPagingItemReader is the following:

/**
 * Create a new {@link JpaPagingItemReader} instance.
 * @param entityManagerFactory the JPA entity manager factory.
 * @since 6.0
*/
public JpaPagingItemReader(EntityManagerFactory entityManagerFactory) {
	Assert.notNull(entityManagerFactory, "EntityManagerFactory must not be null.");
	this.entityManagerFactory = entityManagerFactory;
}

The same apply to the JpaItemWriter:

/**
 * Create a new {@link JpaItemWriter} instance.
 * @param entityManagerFactory the entity manager factory to use
 * @since 6.0
*/
public JpaItemWriter(EntityManagerFactory entityManagerFactory) {
	Assert.notNull(entityManagerFactory, "EntityManagerFactory must not be null");
	this.entityManagerFactory = entityManagerFactory;
}

We should make the field EntityManagerFactory entitiyManagerFactory final as we expect to get a non-null factory and remove the setter associated to this field.

Also the reader/writer should not change of entityManagerFactory during the process, and we should define a new one if we need to change the source entityManagerFactory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions