-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Description
Working on #51279, I keep running into the fact that currently, each Hibernate entity which serves in the Security JPA as the @UserDefinition has predetermined persistence unit based on the package it belongs to. So to my understanding, Hibernate persistence units either have explicitly declared package, or there is just one active persistence unit and from that and the entity package, we can figure which persistence unit to use in case the entity is mapped just to one.
Thus, IMO we can:
- do not require
quarkus.security-jpa.persistence-unit-namefor most cases and just select the persistence unit for users automatically unless one entity is mapped to multiple PUs. In which case, how is it useful to users when we only allow one PU for the user definition entity? - support named persistence units for Hibernate Reactive (I mean in
quarkus-security-jpa-reactive) as well, since we will know the PU name and it is just about the rightio.quarkus.hibernate.orm.PersistenceUnitinjection point qualifier for our session factory
Implementation ideas
I'd have to look into Hibernate internals and see how to get this mapping between entity and persistence unit, but I believe they must have this mapping somewhere. It is only lately when Hibernate was allowed to be started without any entity. Maybe @yrodiere @marko-bekhta or @lucamolteni can give us a hint. Otherwise, we can just figure it out from the code, no problem.
also cc @FroMage since it is about the Security JPA