# HS 6 and referencedColumnName

**URL:** <https://discourse.hibernate.org/t/hs-6-and-referencedcolumnname/5053>\
**Category:** Hibernate Search\
**Created:** [February 12, 2021, 2:22pm UTC](https://discourse.hibernate.org/t/hs-6-and-referencedcolumnname/5053 "2021-02-12T14:22:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zasch](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/zasch/32/1388_2.png) [@Zasch](https://discourse.hibernate.org/u/Zasch)\
**Post date:** [February 12, 2021, 2:22pm UTC](https://discourse.hibernate.org/t/hs-6-and-referencedcolumnname/5053/1 "2021-02-12T14:22:50Z")

</div>

While Upgrading to Hibernate Search 6.0.1 I noticed, that indexing of my bidirectional mapping isn’t working any more.

Contract.java

```auto
@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

```auto
@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

```auto
...

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?

---

<div class="post-metadata">

**Author:** ![yrodiere](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/yrodiere/32/1760_2.png) [@yrodiere](https://discourse.hibernate.org/u/yrodiere)\
**Post date:** [February 12, 2021, 2:29pm UTC](https://discourse.hibernate.org/t/hs-6-and-referencedcolumnname/5053/2 "2021-02-12T14:29:30Z")

</div>

Hello,

This looks like a bug. The fact that Hibernate Search is referring to the property as `_com_example_hsearch_model_Contract_customer` in particular is extremely suspicious.

Could you please show me a reproducer? If your project is private and cannot be shared, you can use [this template](https://github.com/hibernate/hibernate-test-case-templates/tree/master/search/hibernate-search-6/orm-lucene) to copy just enough code to reproduce the problem.

Also, to clarify: you’re upgrading directly from 5.x to 6.0.1.Final, right? You’re not saying this used to work in 6.0.0.Final?

---

<div class="post-metadata">

**Author:** ![Zasch](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/zasch/32/1388_2.png) [@Zasch](https://discourse.hibernate.org/u/Zasch)\
**Post date:** [February 12, 2021, 2:39pm UTC](https://discourse.hibernate.org/t/hs-6-and-referencedcolumnname/5053/3 "2021-02-12T14:39:32Z")

</div>

Hi,

I’m upgrading to 6.0.1, but had the same problem with 6.0.0.

You can find the project on github: [GitHub - Zasch/hsearch](https://github.com/Zasch/hsearch)

---

<div class="post-metadata">

**Author:** ![yrodiere](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/yrodiere/32/1760_2.png) [@yrodiere](https://discourse.hibernate.org/u/yrodiere)\
**Post date:** [February 12, 2021, 3:16pm UTC](https://discourse.hibernate.org/t/hs-6-and-referencedcolumnname/5053/4 "2021-02-12T15:16:18Z")

</div>

Thanks. I confirmed it’s a bug: [[HSEARCH-4156] Hibernate Search incorrectly adds synthetic Hibernate ORM properties to the metamodel, ultimately leading to a bootstrap failure - Hibernate JIRA](https://hibernate.atlassian.net/browse/HSEARCH-4156)

I’ll try to release a fix soon.

In the meantime, the only workaround I could come up with is to remove `@JoinColumn(name = "customer_number", referencedColumnName = "customer_number")` on `Contract#customer`. That will affect your database schema, though.
