Fix logging messages in `ArtistRepository` for clarity

- Correct references from "genre" to "artist" in logging statements.
- Remove unused `Genre` import for cleanup.
This commit is contained in:
Gustavo Henrique Santos Souza de Miranda 2025-11-30 12:59:57 -03:00
parent 3c42fd9735
commit 0df4b31a4d
1 changed files with 4 additions and 6 deletions

View File

@ -1,7 +1,5 @@
package com.mediamanager.repository; package com.mediamanager.repository;
import com.mediamanager.model.Artist; import com.mediamanager.model.Artist;
import com.mediamanager.model.Genre;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import jakarta.persistence.EntityManagerFactory; import jakarta.persistence.EntityManagerFactory;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
@ -62,17 +60,17 @@ public class ArtistRepository {
} }
public Artist update(Artist artist){ public Artist update(Artist artist){
logger.debug("Updating genre ID: {}", artist.getId()); logger.debug("Updating artist ID: {}", artist.getId());
EntityManager em = entityManagerFactory.createEntityManager(); EntityManager em = entityManagerFactory.createEntityManager();
em.getTransaction().begin(); em.getTransaction().begin();
try { try {
Artist updated = em.merge(artist); Artist updated = em.merge(artist);
em.getTransaction().commit(); em.getTransaction().commit();
logger.debug("Genre updated successfully"); logger.debug("Artist updated successfully");
return updated; return updated;
} catch (Exception e) { } catch (Exception e) {
em.getTransaction().rollback(); em.getTransaction().rollback();
logger.error("Error updating genre", e); logger.error("Error updating artist", e);
throw e; throw e;
} finally { } finally {
if (em.isOpen()) em.close(); if (em.isOpen()) em.close();
@ -95,7 +93,7 @@ public class ArtistRepository {
return true; return true;
} catch (Exception e) { } catch (Exception e) {
em.getTransaction().rollback(); em.getTransaction().rollback();
logger.error("Error deleting genre", e); logger.error("Error deleting artist", e);
throw e; throw e;
} finally { } finally {
if (em.isOpen()) em.close(); if (em.isOpen()) em.close();