这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@LeoHelfferich
Copy link
Contributor

No description provided.

@LeoHelfferich LeoHelfferich marked this pull request as ready for review July 9, 2025 20:57
@Autowired
private TestOrderRepository orderRepository;

@Transactional //<-- marks this method
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
@Transactional //<-- marks this method
@Transactional

I think we should omit this, usually the guideline is to describe in the article rather than in comments

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

import jakarta.persistence.Id;
import jakarta.persistence.Table;

import lombok.Getter;
Copy link
Collaborator

Choose a reason for hiding this comment

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

We have a guideline to not use Lombok in articles that aren't specifically demonstrating Lombok features

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

Copy link
Collaborator

Choose a reason for hiding this comment

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

Great! Very clean


@Test
void givenPublicTransactionalMethod_whenCallingIt_thenShouldRollbackOnException() {
assertThat(testOrderRepository.findAll()).isEmpty();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
assertThat(testOrderRepository.findAll()).isEmpty();
assertThat(testOrderRepository.findAll())
.isEmpty();

Let's format the chained method calls on separate lines to make them more visible

Copy link
Contributor Author

@LeoHelfferich LeoHelfferich Jul 12, 2025

Choose a reason for hiding this comment

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

Is this really the right way? I applied the Baeldung code style which, after I added line break like you suggested, corrected it back to the way it is now.

Choose a reason for hiding this comment

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

@LeoHelfferich from the author guidelines:

formatting - fluent APIs

  • sometimes, the default formatter does need a bit of manual help
  • for example, fluent APIs are more readable if we split each method call on its own line
  • if the method call is small enough, and very logically connected to the next one - you can also group 2 on a single line

@theangrydev theangrydev merged commit f355bbb into eugenp:master Jul 16, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants