agoncal-course-quarkus-jpa-panache icon indicating copy to clipboard operation
agoncal-course-quarkus-jpa-panache copied to clipboard

IllegalArgument Not an entity [class org.agoncal.quarkus.jdbc.Artist]

Open real-marty opened this issue 1 year ago • 0 comments

Hello, I'm following an online tutorial, but came across an error which I am not able to resolve.

[ERROR] Errors: [ERROR] ArtistRepositoryTest.shouldCreateAndFindAnArtist:27 » IllegalArgument Not an entity [class org.agoncal.quarkus.jdbc.Artist]

Making the same steps as shown in course. Even copyed the file sources from the repo to try to fix the issue.

ArtistRepositoryTest.java

package repository;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import java.sql.SQLException;

import org.agoncal.quarkus.jdbc.Artist;
import org.agoncal.qurkus.panache.repository.ArtistRepository;
import org.junit.jupiter.api.Test;

import io.quarkus.test.TestTransaction;
import io.quarkus.test.junit.QuarkusTest;
import jakarta.inject.Inject;

@QuarkusTest
public class ArtistRepositoryTest {

    @Inject
    ArtistRepository repository;

    @Test
    @TestTransaction
    public void shouldCreateAndFindAnArtist() throws SQLException {
        Artist artist = new Artist("name", "bio");

        repository.persist(artist);
        assertNotNull(artist.getId());

        artist = repository.findById(artist.getId());
        assertEquals("name", artist.getName());

    }

}

ArtistRepository.java

package org.agoncal.qurkus.panache.repository;

import io.quarkus.hibernate.orm.panache.PanacheRepositoryBase;
import jakarta.enterprise.context.ApplicationScoped;

import org.agoncal.quarkus.jdbc.Artist;

@ApplicationScoped
public class ArtistRepository implements PanacheRepositoryBase<Artist, Long> {

    // Your repository methods here, which can use SQL queries directly.

}

orm.xml

<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"
                 version="2.0">

  <entity class="org.agoncal.quarkus.jdbc.Artist">
    <table name="t_artists"/>
    <attributes>
      <id name="id">
        <generated-value strategy="AUTO"/>
      </id>
    </attributes>
  </entity>
</entity-mappings>

real-marty avatar Sep 15 '23 09:09 real-marty