@Inject PanacheRepository into @QuarkusTest causes "This method is normally automatically overridden in subclasses: did you forget to annotate your entity with @Entity?"

See original GitHub issue

Describe the bug

If the class implementing PanacheRepository is injected into @QuarkusTest, the test will throw infamous “This method is normally automatically overridden in subclasses: did you forget to annotate your entity with @Entity?”

Expected behavior

PanacheRepository implementor is injected and can be used to manipulate entities.

Actual behavior

Throws

Caused by: java.lang.IllegalStateException: This method is normally automatically overridden in subclasses: did you forget to annotate your entity with @Entity?
        at io.quarkus.hibernate.orm.panache.runtime.JpaOperations.implementationInjectionMissing(JpaOperations.java:408)

To Reproduce

Steps to reproduce the behavior:

  1. @Inject PanacheRepository into @QuarkusTest
  2. mvn clean test

Configuration

quarkus.datasource.driver = org.h2.Driver
quarkus.datasource.url=jdbc:h2:mem:test"
quarkus.datasource.username=sa
quarkus.datasource.password=sa

quarkus.hibernate-orm.database.generation=drop-and-create

Screenshots

(If applicable, add screenshots to help explain your problem.)

Environment (please complete the following information):

  • Output of uname -a or ver: Microsoft Windows [Version 10.0.19041.1]
  • Output of java -version:
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)
  • GraalVM version (if different from Java): not tested

  • Quarkus version or git rev: 1.1.0.Final

Additional context

Maven project: rest.zip

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:19 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
geoandcommented, Dec 29, 2019

The issue is known and is being worked on as we speak. The issue is complicated by how junit 5 deals with classloaders, but a solution will be land soon enough.

1reaction
zeljkotcommented, Dec 29, 2019

It would be amazing if you crack this, as Arquillian or other complicated solutions will not be needed anymore.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Simplified Hibernate ORM with Panache - Quarkus
persist(); // note that once persisted, you don't need to explicitly save your entity: all // modifications are automatically persisted on transaction commit....
Read more >
@QuarkusTest throws exception when run as Intellij JUnit 5 ...
Caused by: java.lang.IllegalStateException: This method is normally automatically overridden in subclasses: did you forget to annotate your entity with ...
Read more >
Error using Quarkus Panache Entities with Generic Java ...
I copy/paste here the answer I made on the Github Issue. What you want to do cannot works, it's not a limitation on...
Read more >
Panache - Repository Pattern - Thorben Janssen
Repositories are a very popular pattern for Java-based persistence layers. They encapsulate the database operations you can perform on entity objects and ...
Read more >
Data Persistence with Quarkus and Hibernate Panache
orm.panache.PanacheEntity you will be able to use out of the box some benefits like an ID field that is auto-generated. You can still...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found