Versions:
- Hibernate-Core: 5.2.5.Final
- Hibernate-Search: 5.5.5.Final
Having the following mappings:
@Indexed
@Entity
@Table(name = "scanresult")
public class ScanResult
{
@Id
private ScanResultKey id;
@Field
@Column(name = "name")
private String name;
}
@Embeddable
public class ScanResultKey implements Serializable
{
@ManyToOne
@JoinColumn(name = "eA", referencedColumnName = "id")
private EntityA entA;
//others...
}
I have read in previous posts that this was an issue in Search 4.4
(when having composite id and foreign relations), but this should be fixed in 5.5
. So apparently it is my fault. But I can't figure out what could I do wrong
Exception:
org.hibernate.search.exception.SearchException: HSEARCH000135: Unable to guess FieldBridge for id in entities.keys.ScanResultKey
Note: I only need one field(name
) to be indexed
Could you please point out what I'm doing wrong?
OK, Since this question got interest near to none, according to view count, here is, briefly, the way I managed (hopefully) to resolve the problem (Please, correct me if you know more)
According to one of the commenters in this SO question, not all (even latest) versions are compatible with each other. For example:
Stated by: Sanne
This is not a fix to this particular problem, but might save from other issues
Create a
FieldBridge
for Composite Key implementingTwoWayFieldBridge
public class ScanResultBridge implements TwoWayFieldBridge
Add annotation to Entity Class, specifying the implementation of Bridge
@FieldBridge(impl = ScanResultBridge.class) private ScanResultKey id;