Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to use JpaRepository default implement #1712

Merged

Conversation

wickdynex
Copy link
Contributor

Title:

Refactor to use JpaRepository default implement


Description:

This PR refactor the OwnerRepository, implementing with JpaRepository instead of Repository interface. Remove the rest @Query in OwnerRepository class. Also refactor code logic in test and controller files.


Problem:

Use JpaRepository can auto-generate query, so need to delete the annotations and also rename the method name, rebuild the code logic.


Solution:

  • Replace: use JpaRepository to replace Repository in OwnerRepository class.
  • Rename: rename method findByLastName into findByLastNameStartingWith which can be auto-generate.
  • Remove: remove useless annotations.
  • Refactor: refactor test and controller code logic.

Type of Change

  • New feature
  • Refactor (code restructuring)
  • Rename(rename method)
  • Add validate annotation

Changes:

  • Remove query annotations.
  • Refactor the method related code structure.

Local Test ScreenShot:

image

Additional Information:

This is just a part task to refactor the OwnerRepository with JpaRepository. Also need to do the same thing with VetRepository, but next step is to write more unit tests in PetControllerTests.

<refactor>: remove useless logic cod.
<refactor>: detele useless annotation which is provided by Jpa.
<refactor>: refactor implement of `findByLastName`, use Jpa to simplify query.
@dsyer dsyer merged commit 1cad412 into spring-projects:main Nov 11, 2024
3 checks 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.

2 participants