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

HibernateOrmProcessor complains about abstract model classes not mapped to a PersistenceUnit #22183

Open
renegrob opened this issue Dec 14, 2021 · 6 comments
Labels
area/hibernate-orm Hibernate ORM area/kotlin area/persistence OBSOLETE, DO NOT USE kind/bug Something isn't working

Comments

@renegrob
Copy link
Contributor

renegrob commented Dec 14, 2021

Describe the bug

If hibernate entity packages are explicitly listed (e.g. to map them to a specific PersistenceUnit), the HibernateOrmProcessor complains that their abstract super classes and interfaces are not mapped to a PersistenceUnit:

application.yaml

quarkus:
  hibernate-orm:
    packages:
      - 'com.github.renegrob.entity'

Build output:

./gradlew clean build

> Task :quarkusGenerateCode
preparing quarkus application

> Task :quarkusGenerateCodeTests
preparing quarkus application
Could not find a suitable persistence unit for model classes:
        - com.github.renegrob.INamedEntity
        - io.quarkus.hibernate.orm.panache.PanacheEntity

> Task :quarkusBuild
building quarkus jar

BUILD SUCCESSFUL in 6s

The log message seems to be produced in io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor line 1054.
In my opinion abstract classes (and those annoted with @MappedSuperclass) and interfaces should not be listed - but maybe I'm mistaken.
I would expect that abstract super classes and interfaces can be shared among different PersistentUnits.

Expected behavior

In the describe scenario no such log message is produced.

Actual behavior

See bug description

How to Reproduce?

  1. Checkout https://github.com/renegrob/reproducer-base/tree/no-suitable-persistence-unit
  2. ./gradlew clean build
  3. You will see the following build output:
...
preparing quarkus application
Could not find a suitable persistence unit for model classes:
        - com.github.renegrob.INamedEntity
        - io.quarkus.hibernate.orm.panache.PanacheEntity
...

Output of uname -a or ver

Linux automatix 5.11.0-41-generic #45~20.04.1-Ubuntu SMP Wed Nov 10 10:20:10 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version "11.0.13" 2021-10-19 LTS OpenJDK Runtime Environment Zulu11.52+13-CA (build 11.0.13+8-LTS) OpenJDK 64-Bit Server VM Zulu11.52+13-CA (build 11.0.13+8-LTS, mixed mode)

GraalVM version (if different from Java)

n/a

Quarkus version or git rev

2.5.2.Final

Build tool (ie. output of mvnw --version or gradlew --version)

------------------------------------------------------------
Gradle 7.3.1
------------------------------------------------------------

Build time:   2021-12-01 15:42:20 UTC
Revision:     2c62cec93e0b15a7d2cd68746f3348796d6d42bd

Kotlin:       1.5.31
Groovy:       3.0.9
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          11.0.13 (Azul Systems, Inc. 11.0.13+8-LTS)
OS:           Linux 5.11.0-41-generic amd64

Additional information

No response

@renegrob renegrob added the kind/bug Something isn't working label Dec 14, 2021
@quarkus-bot quarkus-bot bot added area/hibernate-orm Hibernate ORM area/kotlin area/persistence OBSOLETE, DO NOT USE labels Dec 14, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Dec 14, 2021

/cc @Sanne, @evanchooly, @gsmet, @yrodiere

@renegrob
Copy link
Contributor Author

@Sanne
Copy link
Member

Sanne commented Dec 14, 2021

The log message seems to be produced in io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor line 1054.
In my opinion abstract classes (and those annoted with @MappedSuperclass) and interfaces should not be listed - but maybe I'm mistaken.
I would expect that abstract super classes and interfaces can be shared among different PersistentUnits.

Agreed, let's try to improve on this. Thanks!

@YassinHajaj
Copy link

Hi,
Is there news about this one ?

@yrodiere
Copy link
Member

@geoand proposed a simple patch here... but it might be more complicated than that.

We need to check whether:

  1. Not affecting an abstract class to a persistence unit is safe. Maybe it's "implicitly" processed by each PU it's used in, maybe not.
  2. Using the same abstract class in multiple persistence units "implicitly" is safe. It might lead to trouble when it comes to bytecode enhancement in particular, if the class is enhanced differently in different PUs.

@geoand
Copy link
Contributor

geoand commented Feb 20, 2023

Oh, I was not aware there was already an issue about this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/hibernate-orm Hibernate ORM area/kotlin area/persistence OBSOLETE, DO NOT USE kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants