HSEARCH700020: Unable to find the inverse side of the association on type

@Getter
@Setter
@NoArgsConstructor
@Indexed
@Entity
@Table(name = "Posting")
public class Posting implements Serializable {
    
    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @Column(name = "job_name")
    @FullTextField()
    private String jobName;

    @Column(name = "position")
    @FullTextField()
    private String position;

    @Column(name = "descriptions", length = 3000)
    @FullTextField()
    private String description;

    @Column(name = "gender_requirement")
    @FullTextField()
    private String genderRequirement;

    @Column(name = "job_requirement", length = 4000)
    @FullTextField()
    private String jobRequirement;

    @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinTable(name = "posting_address", joinColumns = @JoinColumn(name = "posting_id"),         inverseJoinColumns = @JoinColumn(name = "address_id"))
    @EqualsAndHashCode.Exclude
    @ToString.Exclude
    @JsonIgnore
    @IndexedEmbedded
    private Collection<Address> addresss;

    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinColumn(name = "user_id", referencedColumnName = "id")
    @EqualsAndHashCode.Exclude
    @ToString.Exclude
    @NotNull
    @JsonIgnore
    private User user;
}

@Getter
@Setter
@NoArgsConstructor
@Entity
@Table(name = "Address")
public class Address implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;

	@Column(name = "name")
	private String name;
	
	@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinColumn(name = "province_id", referencedColumnName = "id")
	@EqualsAndHashCode.Exclude
	@ToString.Exclude
	@JsonIgnore
	@IndexedEmbedded
	private Province province;
	
	@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinColumn(name = "city_id", referencedColumnName = "id")
	@EqualsAndHashCode.Exclude
	@ToString.Exclude
	@JsonIgnore
	private City city;
	
	@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinColumn(name = "street_id", referencedColumnName = "id")
	@EqualsAndHashCode.Exclude
	@ToString.Exclude
	@JsonIgnore	
	private Street street;

	@OneToMany(mappedBy = "address", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@EqualsAndHashCode.Exclude
	@ToString.Exclude
	@JsonIgnore
	private Collection<User> users;
}

@Getter
@Setter
@NoArgsConstructor
@Entity
@Table(name = "Province")
public class Province implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;

	@Column(name = "name", unique = true, length = 100)
	@FullTextField
	private String name;

	@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@EqualsAndHashCode.Exclude
	@ToString.Exclude
	@JsonIgnore
	private Collection<City> cities;

	@OneToOne(mappedBy = "province",cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@EqualsAndHashCode.Exclude
	@ToString.Exclude
	@JsonIgnore
	private Address address;
}

I have an error 
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.codedecode.demo.entity.Posting': 
            path '.addresss<collection>.province<no value extractors>.name<no value extractors>': 
                failures: 
                  - HSEARCH700020: Unable to find the inverse side of the association on type 'com.codedecode.demo.entity.Posting' at path '.addresss<collection>'. Hibernate Search needs this information in order to reindex 'com.codedecode.demo.entity.Posting' when 'com.codedecode.demo.entity.Address' is modified. You can solve this error by defining the inverse side of this association,  either with annotations specific to your integration (@OneToMany(mappedBy = ...) in Hibernate ORM)  or with the Hibernate Search @AssociationInverseSide annotation. Alternatively, if you do not need to reindex 'com.codedecode.demo.entity.Posting' when 'com.codedecode.demo.entity.Address' is modified, you can disable automatic reindexing with @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW).
            path '.addresss<collection>.province<no value extractors>': 
                failures: 
                  - HSEARCH700020: Unable to find the inverse side of the association on type 'com.codedecode.demo.entity.Posting' at path '.addresss<collection>'. Hibernate Search needs this information in order to reindex 'com.codedecode.demo.entity.Posting' when 'com.codedecode.demo.entity.Address' is modified. You can solve this error by defining the inverse side of this association,  either with annotations specific to your integration (@OneToMany(mappedBy = ...) in Hibernate ORM)  or with the Hibernate Search @AssociationInverseSide annotation. Alternatively, if you do not need to reindex 'com.codedecode.demo.entity.Posting' when 'com.codedecode.demo.entity.Address' is modified, you can disable automatic reindexing with @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW).
1 Like

I have an error

You also have an explanation, right there in the error message:

Hibernate Search needs this information in order to reindex ‘com.codedecode.demo.entity.Posting’ when ‘com.codedecode.demo.entity.Address’ is modified.

And even two solutions:

You can solve this error by defining the inverse side of this association, either with annotations specific to your integration (@OneToMany(mappedBy = …) in Hibernate ORM) or with the Hibernate Search @AssociationInverseSide annotation.

Alternatively, if you do not need to reindex ‘com.codedecode.demo.entity.Posting’ when ‘com.codedecode.demo.entity.Address’ is modified, you can disable automatic reindexing with @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW)

1 Like

@EricLunaria I have absolutely the same mapping and stuck with it. Did you solve it?

@yrodiere I have to admit - error messages and explanations are really verbose the good way and I can’t remember any other framework giving you solutions inside exception messages. My both thumbs up for this - saved so much time so far having it that way.

Thanks @horvoje! Really appreciated: we’ve put a lot of effort into this, because we knew migration would already be a lot of work and wanted to make it as smooth as possible. Looks like it paid off :slight_smile: