Skip to content

Conversation

@tiborsulyan
Copy link
Contributor

Fixes #28802

Create spring.batch.jdbc.isolation-level-for-create property with the following behavior:

  • Default value is null
  • If not set, Spring Batch with JPA will use ISOLATION_DEFAULT level, and if no JPA is detected, then the Spring Batch default (ISOLATION_SERIALIZABLE) is used. This is the current behavior
  • If the property is set, it will be passed to Spring Batch and used as isolation level for create operations.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 30, 2021
public class BasicBatchConfigurer implements BatchConfigurer, InitializingBean {

private final BatchProperties properties;
protected final BatchProperties properties;
Copy link
Member

Choose a reason for hiding this comment

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

Generally we prefer to keep member variables private. Is there a reason you changed these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From the design of this class it looks like it it's open for extension (see protected methods). However, subclasses cannot access the members those protected methods operate on, even though it's passed to their constructor. I'd suggest either extend the visibility to protected or provide protected getters to these. Since the members are final I think it's safe and would improve extensibility. What do you think?

For this concrete member, the new JpaBatchConfigurer implementation uses the properties too in determineIsolationLevel

Copy link
Member

Choose a reason for hiding this comment

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

Given that the fields don't need to be made protected to implement the configurable isolation level, I think they should be considered via a separate issue please. Even properties could remain private as JpaBatchConfigurer could capture what it needs in its constructor. This would minimise the changes to the public API.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry for the delay. Sure, I'll roll this change back and will consider a separate PR for this.

@snicoll snicoll added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 7, 2022
@snicoll snicoll added this to the 2.7.x milestone Jan 7, 2022
@snicoll
Copy link
Member

snicoll commented Jan 7, 2022

Thanks for the follow-up @tiborsulyan. Spring Batch has added an enum in the next major release so we'd like to create a local enum to improve user experience in 2.7.x. No need to act on it, we'll do it as part of merging it.

@wilkinsona wilkinsona added the for: merge-with-amendments Needs some changes when we merge label Jan 7, 2022
@snicoll snicoll marked this pull request as ready for review January 8, 2022 19:25
@snicoll snicoll changed the title Add option to allow Spring Batch custom isolation levels with JPA Add option to allow Spring Batch custom isolation levels Jan 11, 2022
@snicoll snicoll self-assigned this Jan 11, 2022
@snicoll snicoll closed this in 52b97a2 Jan 11, 2022
@snicoll snicoll modified the milestones: 2.7.x, 2.7.0-M1 Jan 11, 2022
@snicoll
Copy link
Member

snicoll commented Jan 11, 2022

@tiborsulyan thank you for making your first contribution to Spring Boot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

for: merge-with-amendments Needs some changes when we merge type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add option to allow Spring Batch custom isolation levels with JPA

5 participants