Cannot use Hibernate Search’s Standalone POJO and ORM Mapper in one application

It seems there is some conflict between these two. I have everything configured as described in Getting started with Hibernate Search’s Standalone POJO Mapper

but on app startup I am getting this error:

Hibernate ORM mapping:

type ‘<MY CLASS ANNOTATED ONLY WITH @Indexed and @SearchEntity>’:

failures:

- Cannot invoke “org.hibernate.mapping.PersistentClass.getJpaEntityName()” because “persistentClass” is null

at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:421)

at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396)

at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:366)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1853)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1802)

… 209 common frames omitted

Caused by: org.hibernate.search.util.common.SearchException: HSEARCH000520: Hibernate Search encountered failures during bootstrap. Failures:

I use this environment:

  • Spring Boot v3.3.5
  • hibernate-search-mapper-pojo-standalone v7.6.2
  • hibernate-search-mapper-orm v7.6.2
  • hibernate-search-backend-elasticsearch v7.6.2

Is this case not supported or is it a bug? Is there some workaround for this?

Thank you

p.s. I have also registered this topic in Quarkus github that is probably dealing with the same problem: Make it possible to use Hibernate Search Standalone and Hibernate Search with ORM in the same application · Issue #39517 · quarkusio/quarkus · GitHub

Hey :waving_hand: :slightly_smiling_face:

Thanks for reaching out. As you noticed in that Quarkus issue, there are problems with mixing the two mappers (if the ORM mapper picks an indexed entity that is not actually an ORM entity – it doesn’t know how to deal with it ..)

Mixing the two mappers in a single application isn’t something that we test/support, so I wouldn’t call it a bug.

Do you have a particular use case you need to cover by using the two at the same time? Or were you just experimenting?

See also this related improvement: Jira

Thank you for a quick answer. And yes, we have a particular use case. We would like to index non-ORM entity that is stored in another system to be able to search in them like with our other ORM entities.