Skip to content

Refactored DatabaseFiller#3

Merged
OskarLundqvist33 merged 1 commit intomainfrom
branch/workingbranch
Dec 17, 2025
Merged

Refactored DatabaseFiller#3
OskarLundqvist33 merged 1 commit intomainfrom
branch/workingbranch

Conversation

@OskarLundqvist33
Copy link
Copy Markdown

@OskarLundqvist33 OskarLundqvist33 commented Dec 17, 2025

Made sure the databasefiller doesn't create duplicates and works for the future of the application (hopefully)

Summary by CodeRabbit

Release Notes

  • Refactor

    • Restructured database initialization into independent, modular components for improved maintainability.
    • Standardized entity equality comparison logic across domain objects.
    • Enhanced movie-actor-director relationship management with additional utility methods.
  • Bug Fixes

    • Improved actor lookup with case-insensitive, trimmed name matching to prevent duplicates.

✏️ Tip: You can customize this high-level summary in your review settings.

Made sure the databasefiller doesn't create duplicates and works for the future of the application (hopefully)

Co-authored-by: Oscar Nidemar <oscar.nidemar@gmail.com>
Co-authored-by: Oskar Lundqvist <oskar.lundqvist3@icloud.com>
Co-authored-by: Mark Cavric <cavric_123@hotmail.se>
Co-authored-by: Linus Westling <westling.linus@gmail.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Dec 17, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The PR extracts database seeding logic from DatabaseFiller into five separate seed classes (SeedGenres, SeedActors, SeedDirectors, SeedMovies, SeedUsers), which are invoked sequentially from App.java within a single transactional boundary. Repository method names are updated (getByIdfindById), input validation is improved (trimming, case-insensitive checks), relationship accessors are added to POJOs, and equals/hashCode methods are implemented across domain classes.

Changes

Cohort / File(s) Summary
Seed Refactoring
src/main/java/org/example/App.java, src/main/java/org/example/DatabaseFiller.java, src/main/java/org/example/SeedGenres.java, src/main/java/org/example/SeedActors.java, src/main/java/org/example/SeedDirectors.java, src/main/java/org/example/SeedMovies.java, src/main/java/org/example/SeedUsers.java
Extracted seeding methods from DatabaseFiller into individual Seed* classes; App.java now instantiates and invokes each seed class in sequence within the same transaction. Removals of seedActors(), seedDirectors(), seedMovies(), seedGenres(), seedUsers() from DatabaseFiller.
Repository Interface Updates
src/main/java/org/example/repo/ActorRepo.java, src/main/java/org/example/repo/DirectorRepo.java, src/main/java/org/example/repo/MovieRepo.java
Renamed getById(Long)findById(Long) in Actor and Director repos; added three new methods to MovieRepo: addActorToMovie(Long, Long), addActorToMovie(Movie, Actor), setDirector(Long, Long).
Repository Implementation Updates
src/main/java/org/example/jpaimpl/ActorRepoJpa.java, src/main/java/org/example/jpaimpl/DirectorRepoJpa.java, src/main/java/org/example/jpaimpl/MovieRepoJpa.java
Renamed getById()findById() in Actor and Director; enhanced ActorRepoJpa with trimmed and case-insensitive name lookup; added implementations of addActorToMovie() and setDirector() with bidirectional relationship updates in MovieRepoJpa.
POJO Relationship Accessors
src/main/java/org/example/pojo/Actor.java, src/main/java/org/example/pojo/Director.java, src/main/java/org/example/pojo/Movie.java
Added public getters/setters for movie collections: setMovies() in Actor; getMovies() and setMovies() in Director; getActors(), setActors(), getDirector(), setDirector() in Movie.
POJO Equals/HashCode & Type Checks
src/main/java/org/example/pojo/Actor.java, src/main/java/org/example/pojo/Director.java, src/main/java/org/example/pojo/Genre.java, src/main/java/org/example/pojo/Movie.java, src/main/java/org/example/pojo/User.java, src/main/java/org/example/equals-hashcode-suggestions
Implemented equals and hashCode methods using id-based comparison; replaced pattern-matching instanceof checks with explicit null and getClass() comparisons in equals methods.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • ActorRepoJpa logic changes: Review trimming and case-insensitive query updates; ensure backward compatibility with existing lookups.
  • Transactional semantics in App.java: Verify that extracting seed calls into separate classes preserves atomicity and rollback behavior.
  • Bidirectional relationship updates in MovieRepoJpa: Confirm both sides of relationships are properly managed when adding actors/directors.
  • POJO equals/hashCode implementations: Audit id-based equality semantics and verify consistency across all domain classes.
  • Method rename cascade: Ensure all callers of getById()findById() have been updated across the codebase.

Possibly related PRs

  • feature/entityImpl #1 (feature/entityImpl): Introduced initial seed methods in DatabaseFiller and the database initialization pattern that this PR refactors into separate, reusable seed classes.

Poem

🐰 The seeds once buried deep within one jar,
Now bloom as friends, each playing their own part—
Genres, Actors, Directors shining bright,
One transaction holding all so tight!

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch branch/workingbranch

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4a9582a and a5200f4.

📒 Files selected for processing (19)
  • src/main/java/org/example/App.java (2 hunks)
  • src/main/java/org/example/DatabaseFiller.java (1 hunks)
  • src/main/java/org/example/SeedActors.java (1 hunks)
  • src/main/java/org/example/SeedDirectors.java (1 hunks)
  • src/main/java/org/example/SeedGenres.java (1 hunks)
  • src/main/java/org/example/SeedMovies.java (1 hunks)
  • src/main/java/org/example/SeedUsers.java (1 hunks)
  • src/main/java/org/example/equals-hashcode-suggestions (1 hunks)
  • src/main/java/org/example/jpaimpl/ActorRepoJpa.java (2 hunks)
  • src/main/java/org/example/jpaimpl/DirectorRepoJpa.java (1 hunks)
  • src/main/java/org/example/jpaimpl/MovieRepoJpa.java (1 hunks)
  • src/main/java/org/example/pojo/Actor.java (3 hunks)
  • src/main/java/org/example/pojo/Director.java (2 hunks)
  • src/main/java/org/example/pojo/Genre.java (1 hunks)
  • src/main/java/org/example/pojo/Movie.java (1 hunks)
  • src/main/java/org/example/pojo/User.java (1 hunks)
  • src/main/java/org/example/repo/ActorRepo.java (1 hunks)
  • src/main/java/org/example/repo/DirectorRepo.java (1 hunks)
  • src/main/java/org/example/repo/MovieRepo.java (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@OskarLundqvist33 OskarLundqvist33 merged commit 6f283fc into main Dec 17, 2025
1 of 2 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.

1 participant