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

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

Open
real-marty opened this issue Sep 15, 2023 · 0 comments
Open

Comments

@real-marty
Copy link

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>

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

No branches or pull requests

1 participant