-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Named persistence unit is broken in hibernate-orm-panache-kotlin 2.0.0.Final+ #18263
Comments
/cc @FroMage, @Sanne, @evanchooly, @gsmet, @loicmathieu, @yrodiere |
Thanks for the report. Looks like a very weird issue, any chance you could share a small reproducer? |
@gsmet |
@evanchooly could you have a look to see if it's a Kotlin-specific issue? We have tests for multiple persistence units support for Java I think so maybe it's a corner case but it might as well be Kotlin-related. Thanks. |
FYI, switching to @Entity
@Table
class Admin(
@Id
@GeneratedValue
var id: Long = -1,
var name: String = ""
)
@Singleton
class AdminRepository : PanacheRepository<Admin> |
after poking around the kotlin bits for a while i converted the project to use java. I get the same error after doing that as I did with kotlin (as shown above). So there's something off here for sure but i'm not 100% it's kotlin related. Perhaps one of the hibernate devs can take a look. @Sanne @FroMage? |
I can look, can you share your Java reproducer please? |
Thanks |
I'm likely missing something obvious to someone more familiar with hibernate's innards but I ran out of places to poke around. |
After quite a lot of hair pulling due to config and trying to follow the multi-tenant docs at https://quarkus.io/guides/hibernate-orm#multitenancy I had to:
And then I tried it, and it works. I do get the following exceptions on startup, though, but I think that's another issue:
I can't quite understand why you had one data source as multitenant: https://github.com/bboyz269/hibernate-orm-panache-kotlin-multi-persistence-unit/blob/main/src/main/resources/application.yml#L21 Is it by mistake or on purpose? |
My working project is at https://github.com/FroMage/quarkus-java-multi-pu |
It's intended. To say briefly, in order to resolve the tenant (which db schema to use for which tenant), my app needs to access another "admin" database, which manage all the tenant information. Are you suggesting that adding "TenantResolver" for each persistence unit would solve the problem? |
I suppose so, at least I had an error when I tried your config. |
@FroMage I tried and got the same result (error due to AbstractJpaOperations#entityToPersistenceUnit being empty). I seems that |
I did some more digging on One is build time work ( The other is runtime work ( I don't have any knowledge of Quarkus's extension framework ("Favor build time work over runtime work") but it seems that the former does not register Do you think this worth investigating @evanchooly @FroMage ? |
@evanchooly could you look at this please? |
Definitely. |
There is a report of the same issue here: #20882 and I chased it down to the same causes, the entity to PU map is empty inside the Kotlin extension. @evanchooly @FroMage did you make any progress on it ? Both Hibernate and Kotlin does it inside a |
Pretty sure this was fixed in a later release |
I just tested that this issue still exists in .2.4.0.Final". |
Fixed by #21079 |
Describe the bug
I have 2 persistence units "admin" and "customer" associate with "c.s.c.e.admin" and "c.s.c.e.customer" packages.
Expected behavior
c.s.c.e.admin.Entity should work properly as before (1.13.6.Final).
Actual behavior
c.s.c.e.admin.Entity failed due to not able to resolve the associated persistence unit.
Masked stacktrace
Configuration
Screenshots
Direct cause would be
AbstractJpaOperations.entityToPersistenceUnit
lost it value (reverted after being set) to default emptyentityToPersistenceUnit map is being set (12 entries)

entityToPersistenceUnit is empty while being used

Reproduce steps
https://github.com/bboyz269/hibernate-orm-panache-kotlin-multi-persistence-unit
The text was updated successfully, but these errors were encountered: