javahibernateunit-testingquarkusbootstrapping

Use Hibernate entities only on test classpath in Quarkus


I have a project that will do plain, rather generic SQL in the main code for merging two equivalent tenant databases (e.g. having the same schema but different data). I want to be able to test this application and generate schema's and data in the (unit) tests and use Hibernate for that, so I create a mini JPA model in src/test/java/entities, but when I run quarkus dev, Hibernate complains that it is disabled because it can't find any entities:

WARN  [io.qua.hib.orm.dep.HibernateOrmProcessor] (build-27) Hibernate ORM is disabled because no JPA entities were found

I don't want to pollute my application with these model classes that exist purely for testing purposes. Is there a way to bind the Hibernate bootstrap to the test class path?

Searching for the usual terms (e.g. hibernate quarkus test class path) give no relevant results.


Solution

  • Quarkus dev mode doesn't use any of files under src/test.
    If you want to have entities and Hibernate available only during test just add <scope>test</scope> to io.quarkus:quarkus-hibernate-orm dependency in pom.xml and all should be solved.