While Upgrading to Hibernate Search 6.0.1 I noticed, that indexing of my bidirectional mapping isn’t working any more.
Contract.java
@Entity
@Indexed
public class Contract implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@FullTextField(searchable = Searchable.YES)
private String contractNumber;
@IndexedEmbedded(includeDepth = 1)
@NotNull
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "customer_number", referencedColumnName = "customer_number")
private Customer customer;
}
and Customer.java
@Entity
public class Customer implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@GenericField(searchable = Searchable.YES)
@NotNull
@Column(name = "customer_number", unique = true, nullable = false)
private Long customerNumber;
@FullTextField(searchable = Searchable.YES)
private String firstName;
@FullTextField(searchable = Searchable.YES)
private String lastName;
@OneToMany(mappedBy = "customer", cascade = CascadeType.ALL)
private List<Contract> contracts = new ArrayList<>();
}
Following the migration guide I assumed that getting rid of the @ContainedIn and exchanging the @Field to the new @*Field annotations would be sufficient. But now, when I try to run my application, I get
...
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.search.util.common.SearchException: HSEARCH000520: Hibernate Search encountered failures during bootstrap. Failures:
Hibernate ORM mapping:
type 'com.example.hsearch.model.Contract':
path '.customer<no value extractors>.customerNumber<no value extractors>':
failures:
- HSEARCH700021: Unable to apply path '._com_example_hsearch_model_Contract_customer<no value extractors>' to type 'com.example.hsearch.model.Customer'. This path was resolved as the inverse side of the association '.customer<no value extractors>' on type 'com.example.hsearch.model.Contract'. Hibernate Search needs to apply this path in order to reindex 'com.example.hsearch.model.Contract' when 'com.example.hsearch.model.Customer' is modified. Nested exception: HSEARCH700078: No readable property named '_com_example_hsearch_model_Contract_customer' on type 'com.example.hsearch.model.Customer'.
path '.customer<no value extractors>.firstName<no value extractors>':
failures:
- HSEARCH700021: Unable to apply path '._com_example_hsearch_model_Contract_customer<no value extractors>' to type 'com.example.hsearch.model.Customer'. This path was resolved as the inverse side of the association '.customer<no value extractors>' on type 'com.example.hsearch.model.Contract'. Hibernate Search needs to apply this path in order to reindex 'com.example.hsearch.model.Contract' when 'com.example.hsearch.model.Customer' is modified. Nested exception: HSEARCH700078: No readable property named '_com_example_hsearch_model_Contract_customer' on type 'com.example.hsearch.model.Customer'.
path '.customer<no value extractors>.lastName<no value extractors>':
failures:
- HSEARCH700021: Unable to apply path '._com_example_hsearch_model_Contract_customer<no value extractors>' to type 'com.example.hsearch.model.Customer'. This path was resolved as the inverse side of the association '.customer<no value extractors>' on type 'com.example.hsearch.model.Contract'. Hibernate Search needs to apply this path in order to reindex 'com.example.hsearch.model.Contract' when 'com.example.hsearch.model.Customer' is modified. Nested exception: HSEARCH700078: No readable property named '_com_example_hsearch_model_Contract_customer' on type 'com.example.hsearch.model.Customer'.
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:421) ~[spring-orm-5.3.3.jar:5.3.3]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[spring-orm-5.3.3.jar:5.3.3]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) ~[spring-orm-5.3.3.jar:5.3.3]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1847) ~[spring-beans-5.3.3.jar:5.3.3]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1784) ~[spring-beans-5.3.3.jar:5.3.3]
... 17 common frames omitted
Caused by: org.hibernate.search.util.common.SearchException: HSEARCH000520: Hibernate Search encountered failures during bootstrap. Failures:
Hibernate ORM mapping:
type 'com.example.hsearch.model.Contract':
path '.customer<no value extractors>.customerNumber<no value extractors>':
failures:
- HSEARCH700021: Unable to apply path '._com_example_hsearch_model_Contract_customer<no value extractors>' to type 'com.example.hsearch.model.Customer'. This path was resolved as the inverse side of the association '.customer<no value extractors>' on type 'com.example.hsearch.model.Contract'. Hibernate Search needs to apply this path in order to reindex 'com.example.hsearch.model.Contract' when 'com.example.hsearch.model.Customer' is modified. Nested exception: HSEARCH700078: No readable property named '_com_example_hsearch_model_Contract_customer' on type 'com.example.hsearch.model.Customer'.
path '.customer<no value extractors>.firstName<no value extractors>':
failures:
- HSEARCH700021: Unable to apply path '._com_example_hsearch_model_Contract_customer<no value extractors>' to type 'com.example.hsearch.model.Customer'. This path was resolved as the inverse side of the association '.customer<no value extractors>' on type 'com.example.hsearch.model.Contract'. Hibernate Search needs to apply this path in order to reindex 'com.example.hsearch.model.Contract' when 'com.example.hsearch.model.Customer' is modified. Nested exception: HSEARCH700078: No readable property named '_com_example_hsearch_model_Contract_customer' on type 'com.example.hsearch.model.Customer'.
path '.customer<no value extractors>.lastName<no value extractors>':
failures:
- HSEARCH700021: Unable to apply path '._com_example_hsearch_model_Contract_customer<no value extractors>' to type 'com.example.hsearch.model.Customer'. This path was resolved as the inverse side of the association '.customer<no value extractors>' on type 'com.example.hsearch.model.Contract'. Hibernate Search needs to apply this path in order to reindex 'com.example.hsearch.model.Contract' when 'com.example.hsearch.model.Customer' is modified. Nested exception: HSEARCH700078: No readable property named '_com_example_hsearch_model_Contract_customer' on type 'com.example.hsearch.model.Customer'.
at org.hibernate.search.engine.reporting.spi.RootFailureCollector.checkNoFailure(RootFailureCollector.java:50) ~[hibernate-search-engine-6.0.1.Final.jar:6.0.1.Final]
at org.hibernate.search.engine.common.impl.SearchIntegrationBuilderImpl.prepareBuild(SearchIntegrationBuilderImpl.java:261) ~[hibernate-search-engine-6.0.1.Final.jar:6.0.1.Final]
at org.hibernate.search.mapper.orm.bootstrap.impl.HibernateOrmIntegrationBooterImpl.doBootFirstPhase(HibernateOrmIntegrationBooterImpl.java:259) ~[hibernate-search-mapper-orm-6.0.1.Final.jar:6.0.1.Final]
at org.hibernate.search.mapper.orm.bootstrap.spi.HibernateOrmIntegrationBooterBehavior.bootFirstPhase(HibernateOrmIntegrationBooterBehavior.java:17) ~[hibernate-search-mapper-orm-6.0.1.Final.jar:6.0.1.Final]
at org.hibernate.search.mapper.orm.bootstrap.impl.HibernateOrmIntegrationBooterImpl.lambda$bootNow$7(HibernateOrmIntegrationBooterImpl.java:218) ~[hibernate-search-mapper-orm-6.0.1.Final.jar:6.0.1.Final]
at java.base/java.util.Optional.orElseGet(Optional.java:362) ~[na:na]
at org.hibernate.search.mapper.orm.bootstrap.impl.HibernateOrmIntegrationBooterImpl.bootNow(HibernateOrmIntegrationBooterImpl.java:218) ~[hibernate-search-mapper-orm-6.0.1.Final.jar:6.0.1.Final]
at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642) ~[na:na]
at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506) ~[na:na]
at java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2137) ~[na:na]
at org.hibernate.search.mapper.orm.bootstrap.impl.HibernateSearchSessionFactoryObserver.sessionFactoryCreated(HibernateSearchSessionFactoryObserver.java:41) ~[hibernate-search-mapper-orm-6.0.1.Final.jar:6.0.1.Final]
at org.hibernate.internal.SessionFactoryObserverChain.sessionFactoryCreated(SessionFactoryObserverChain.java:35) ~[hibernate-core-5.4.27.Final.jar:5.4.27.Final]
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:382) ~[hibernate-core-5.4.27.Final.jar:5.4.27.Final]
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:469) ~[hibernate-core-5.4.27.Final.jar:5.4.27.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1259) ~[hibernate-core-5.4.27.Final.jar:5.4.27.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:58) ~[spring-orm-5.3.3.jar:5.3.3]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[spring-orm-5.3.3.jar:5.3.3]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[spring-orm-5.3.3.jar:5.3.3]
... 21 common frames omitted
Am I missing something or have I misread the documentation somehow?