MediaManager-core/src/main
Gustavo Henrique Santos Souza de Miranda e51d5aa678 Add bidirectional Genre relationship to Album entity
This commit extends the Album entity with bidirectional relationship
  management for the AlbumHasGenre join table, enabling many-to-many
  associations between albums and genres with convenient helper methods.

  Key enhancements:

  Relationship Mapping:
  - Added OneToMany relationship from Album to AlbumHasGenre
    * Bidirectional mapping with cascade ALL and orphan removal
    * Maintains collection of album-genre associations
    * Initialized as ArrayList to prevent null pointer exceptions
    * Follows the same pattern as albumArtists relationship

  Helper Methods for Genre Management:
  - addGenre(Genre genre):
    * Creates AlbumHasGenre join table entry
    * Sets bidirectional references to Album and Genre
    * Adds association to albumGenres collection
    * Simplifies adding genres to albums programmatically

  - removeGenre(Genre genre):
    * Removes association by comparing genre IDs
    * Safely handles null checks
    * Uses removeIf for clean collection manipulation
    * Maintains referential integrity

  - getGenres():
    * Convenience method to extract Genre list from join table
    * Uses Java streams for clean transformation
    * Maps AlbumHasGenre → Genre
    * Returns List<Genre> for easy consumption

  Collection Management:
  - Added getAlbumGenres() getter
    * Returns full List<AlbumHasGenre> for direct access
    * Useful for repository-level operations

  - Added setAlbumGenres() setter
    * Allows bulk replacement of genre associations
    * Required by JPA for entity hydration

  Benefits:
  - Enables navigating from Album to associated Genres
  - Simplifies genre association management in service layer
  - Cascade operations ensure join table entries are managed automatically
  - Orphan removal prevents orphaned join table entries
  - Consistent API with existing Artist relationship methods
  - Type-safe genre management through helper methods

  Pattern Consistency:
  This implementation mirrors the albumArtists relationship structure,
  providing a consistent API for managing both artist and genre associations
  on the Album entity. Both relationships use the same cascade and orphan
  removal strategies for reliable data integrity.

  🤖 Generated with [Claude Code](https://claude.com/claude-code)

  Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

  This commit message is ready to use in IntelliJ for the Album.java changes!
2025-12-07 23:31:07 -03:00
..
java/com/mediamanager Add bidirectional Genre relationship to Album entity 2025-12-07 23:31:07 -03:00
proto Implement AlbumHasGenre relationship management with CRUD operations 2025-12-07 23:24:52 -03:00
resources Merge pull request #7 from gmbrax/feature/IPC-Unix-Socket 2025-11-22 23:41:12 -03:00