HSEARCH700030: there is a cyclic dependency involving path (Bug ?)

Hi everyone,

I discovered lastly a use case on Indexing mapping with HSearch. This example leads toward directly an error of indexation, which is :

org.hibernate.search.util.common.SearchException: HSEARCH700030: Unable to resolve dependencies of a derived property: there is a cyclic dependency involving path ‘.typeActe’ on type ‘com.allegoria.notariat.business.ActePrive’. A derived properties cannot be marked as derived from itself, even indirectly through other derived properties. If your model actually contains such cyclic dependency, you should consider disabling automatic reindexing, at least partially using @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.NO) on one of the properties in the cycle.

Below the code causing this error :

@MappedSuperclass
public abstract class BasicActe extends BusinessObject implements ISearchableEntity {

@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "type_acte_fk")
	protected TypeActe typeActe;

@IndexedEmbedded(includePaths = { TypeActe_.LIBELLE})
	@IndexingDependency(
			derivedFrom = {@ObjectPath({@PropertyValue(propertyName = Acte_.TYPE_ACTE)})}
	)
	public TypeActe getTypeActe() {
		return this.typeActe;
	}

public void setTypeActe(TypeActe typeActe) {
		this.typeActe = typeActe;
	}
}

And probably the code quoted in error message :

@XmlRootElement(name = "ActePrive")
@Entity
@Indexed
@PrimaryKeyJoinColumn(name = "ID")
@Inheritance(strategy = InheritanceType.JOINED)
@Scope(proxyMode = ScopedProxyMode.TARGET_CLASS)
public class ActePrive extends BasicActePrive implements HasRedacteur, ISearchableEntity {
...
}

The inheritance chain (not important) : ActePrive (child) → BasicActePrive → Acte → BasicActe (root)

I found a way to bypass this error :

@IndexedEmbedded(name ="IndexNameOfThisTypeActe", includePaths = { TypeActe_.LIBELLE})
	@IndexingDependency(
			derivedFrom = {@ObjectPath({@PropertyValue(propertyName = Acte_.TYPE_ACTE)})}
	)
	public TypeActe getTypeActe() {
		return this.typeActe;
	}

By simply adding name ="IndexNameOfThisTypeActe". Where as this name is just for HSearch output (kind of Orm property alias) - or referenced by other indexed properties, it should not hide the error isn’t it ?

Hello,

The solution is exactly what the error message is telling you. This code does not make sense:

You’re telling Hibernate Search that typeActe is derived from typeActe. Evidently, the property is not computed from another property, so just remove @IndexingDependency(derivedFrom = ...) and it should work.

I recommend you have a look at this section of the documentation to understand how derivedFrom is used.

Regarding why the error is hidden by assigning a name to the @IndexedEmbedded… that’s odd, indeed. I will look into it.

Hello,

I just tried another test on another (newly) indexed property, and appearently it is a false alarm. Forcing a name does not hide the error.

1 Like