quarkus
quarkus copied to clipboard
Implement per persistence unit configuration for Hibernate Envers
Hibernate Envers actually has the existing infrastructure to do so as we implement the active
boolean per persistence unit but all the rest of the config is still global.
We should move everything to the persistence unit specific config, adjust HibernateEnversRecorder#contributeBootProperties()
to target per PU config for all properties and it would probably work. If we're lucky.
We also need a proper test for that new feature.
Typically, we want to be able to do:
quarkus.hibernate-envers.db1.store-data-at-delete=true
quarkus.hibernate-envers.db1.audit-table-suffix=_aud
quarkus.hibernate-envers.db1.revision-field-name=rev
quarkus.hibernate-envers.db1.revision-type-field-name=revtype
quarkus.hibernate-envers.db1.audit-strategy=org.hibernate.envers.strategy.ValidityAuditStrategy
quarkus.hibernate-envers.db1.audit-strategy-validity-end-rev-field-name=revend
quarkus.hibernate-envers.db1.audit-strategy-validity-store-revend-timestamp=true
quarkus.hibernate-envers.db1.audit-strategy-validity-revend-timestamp-field-name=revend_tstmp
quarkus.hibernate-envers.db2.audit-table-suffix=_aud
quarkus.hibernate-envers.db2.revision-field-name=revision_id
quarkus.hibernate-envers.db2.revision-type-field-name=revtype
quarkus.hibernate-envers.db2.do-not-audit-optimistic-locking-field=false
quarkus.hibernate-envers.db2.store-data-at-delete=true
Discussed in https://github.com/quarkusio/quarkus/discussions/27971
Originally posted by Traivor September 15, 2022 It doesn't appear that the hibernate-envers plugin supports configuration on a persistence unit basis. Am I reading things right? Are there any plans to support this?
Alternatively, would passing envers properties via the new quarkus.hibernate-orm."unit-name".unsupported-properties property work?
/cc @Sanne, @yrodiere
@tmihalac I wonder if you would be interested in taking this one?
@tmihalac I wonder if you would be interested in taking this one?
Yes I will take it.
@gsmet How do I add the properties to the config per persistence unit in HibernateEnversRecorder#contributeBootProperties()
?
How do I change HibernateEnversProcessor#registerEnversReflections()
in regards to the config ?
@tmihalac the properties at the root of HibernateEnversBuildTimeConfig
will need to be migrated to HibernateEnversBuildTimeConfigPersistenceUnit
.
and then I would say you already have the general idea in contributeBootProperties
given it's implemented for the one property in HibernateEnversBuildTimeConfigPersistenceUnit
.
As for HibernateEnversProcessor#registerEnversReflections()
you will have to go through the properties of the default persistence unit and the named ones and register all that's necessary.
Is it clear enough?
In general I understood that, but how do I differentiate the properties of each PersistenceUnit? can you give me an example ? what is the xxx in this case the same as it is today ? addConfig(propertyCollector, xxx, config.storeDataAtDelete);
It's not exactly obvious but the propertyCollector
is specific to the current persistence unit so you just have to push things there from the puConfig
you get from the config.
As for
HibernateEnversProcessor#registerEnversReflections()
you will have to go through the properties of the default persistence unit and the named ones and register all that's necessary.
What do you mean ?
Typically that this:
buildTimeConfig.revisionListener.ifPresent(s -> reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, s)));
buildTimeConfig.auditStrategy.ifPresent(s -> reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, s)));
will need to be done for all the PUs once these properties are moved to PU-specific properties.