We’re trying to upgrade from Hibernate Search v.5 to v.6.
Our JPAs use BigDecimal (not Long) as our primary key / @Id.
Hibernate Search 5 handles this fine, and but Hibernate Search 6 gives this error:
org.hibernate.search.util.common.SearchException: HSEARCH700001: Unable to find a default identifier bridge implementation for type 'java.math.BigDecimal'
at org.hibernate.search.mapper.pojo.bridge.mapping.impl.BridgeResolver.resolveIdentifierBinderForType(BridgeResolver.java:113)
at org.hibernate.search.mapper.pojo.mapping.building.impl.PojoIndexModelBinderImpl.bindIdentifier(PojoIndexModelBinderImpl.java:87)
...
I tried to create a bridge class that implements IdentifierBridge, to work around this:
public class DocumentIdBridge implements IdentifierBridge<BigDecimal> {
@Override
public String toDocumentIdentifier(BigDecimal value, IdentifierBridgeToDocumentIdentifierContext context) {
return value.toString();
}
@Override
public BigDecimal fromDocumentIdentifier(String documentIdentifier, IdentifierBridgeFromDocumentIdentifierContext context) {
return new BigDecimal(documentIdentifier);
}
}
but your @IndentifierBridgeRef.type complains that “The value for annotation attribute DocumentId.identifierBridge must be some @org.hibernate.search.mapper.pojo.bridge.mapping.annotation.IdentifierBridgeRef annotation”.
This looks like a compiler error, not a Hibernate Search error.
Please show me your @DocumentId annotation, and the stack trace if any.
By the way, if the built-in default bridges are not enough for you, you can register your own, so you don’t have to use @DocumentId(identifierBridge = ...) everywhere. See this section of the documentation.
It looks OK to me, but your compiler will know best
Just remove the @DocumentId(identifierBridge = @IdentifierBridgeRef(type = DocumentIdBridge.class)) annotation from your id property. If Hibernate Search still boots without any exception, then you’ll know that your mapping configurer works correctly.