I’m not sure this is going to work.
We’ve only anticipated JSON mapping from strings so far (HSEARCH-1526), never relying on SqlTypes.JSON.
Your main challenge will probably be to have Hibernate Search not fail on bootstrap because it can’t find the properties of your Workflow
class in the Hibernate ORM metamodel.
I can imagine a few hacks, but haven’t tested them. Please report back if something works.
First solution (unlikely to work, but worth a try):
@IndexedEmbedded
@IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW)
@Column
@JdbcTypeCode(SqlTypes.JSON)
private Workflow workflow;
public class Workflow {
@FullTextField
private String name;
}
See Hibernate Search 7.0.0.Final: Reference Documentation
Second solution (a bit uglier, but more likely to work):
@Column
@JdbcTypeCode(SqlTypes.JSON)
private Workflow workflow;
@Transient
@IndexedEmbedded(name = "workflow")
@IndexingDependency(derivedFrom = @ObjectPath({
@PropertyValue(propertyName = "workflow")
}))
public Workflow getWorkflowForIndexing() {
return workflow;
}
public class Workflow {
@FullTextField
private String name;
}
See Hibernate Search 7.0.0.Final: Reference Documentation
Third solution (much more likely to work, at the cost of never getting your entity reindexed when Workflow
changes):
@IndexedEmbedded
@IndexingDependency(reindexOnUpdate = ReindexOnUpdate.NO)
@Column
@JdbcTypeCode(SqlTypes.JSON)
private Workflow workflow;
public class Workflow {
@FullTextField
private String name;
}
See Hibernate Search 7.0.0.Final: Reference Documentation