Make Hibernate Search be compatible with Envers

Description

Expected behavior

I would like to mix hibernate search and envers together. The main goal would be to be able to audit my entity and to have a searchable projection of it using elasticsearch. I do not want to have a representation in elasticsearch of _aud tables and DefaultRevisionEntity.

Current behavior

I made a Quarkus POC to reproduce the current behavior.

The application fails to start due to an exception thrown at startup:

To Reproduce

Steps to reproduce the behavior:

1. git clone https://github.com/dcdh/poc-quarkus-persistence.git
2. checkout branch search_with_auditing
3. run the application using the script run_dev.sh

Additional information

The exception occurs because the auditable table is not associated with a JPA entity.

The impacted code is this one from the class HibernateOrmBootstrapIntrospector :

The auditable tabe is considered as a persistentClasses and when the code will try to collect all embeded type recursively an exception will be thrown and the application will fail.

I notice that for an audited table the className property is null. Maybe that it could be a solution to filter and reject all table persistentClasses having a null className ? and add a special case (or not) regarding the DefaultRevisionEntity but it will introduce a high coupling with Envers...

Quarkus opened issue:

 

Regards,

Damien

Environment

hibernate-search-mapper-orm

Activity

Show:
Damien Clement d'Huart
August 26, 2019, 10:03 PM
Edited

I’ve found some clue here AdditionalJaxbMappingProducerImpl about an EnversService

However in hibernate core… should not touch.

Yoann Rodière
August 27, 2019, 5:41 AM

Thanks for the report and insightful analysis. We'll look into this.

I think a first step would be to migrate the Envers tests from Search 5 to Search 6, preferably in a separate module (hibernate-search-integrationtest-mapper-orm-envers, something like that). Then we'll see what we can do.

Yoann Rodière
August 27, 2019, 5:49 AM

Ok, so you even sent a PR, I missed that Continuing the discussion there.

Fixed

Assignee

Damien Clement d'Huart

Reporter

Damien Clement d'Huart

Labels

None

Suitable for new contributors

None

Feedback Requested

None

Fix versions

Affects versions

Priority

Major
Configure