Default IdentifierBridge/ValueBridge implementations relying on Hibernate ORM's JavaType#toString/JavaType#fromString

Description

org.hibernate.type.descriptor.java.JavaType provides a toString and a fromString method, which could map rather well to the Identifier#toDocumentIdentifier / Identifier#fromDocumentIdentifier or ValueBridge<?, String>#toIndexedValue / ValueBridge<?, String>#fromIndexedValue methods.

We could provide a better out-of-the box experience, and remove the need for custom bridges in some cases, if, when we don’t find a relevant bridge for a given type:

  • We look at the value being mapped

  • If that value is a @Basic property without container extractor, or an @ElementCollection of a basic type, we extract the corresponding JavaType

  • We default to a bridge that delegates to that JavaType as of the corresponding mapped property

  • If

Notes:

  • This can apply to document identifiers, in particular composite ones; see https://hibernate.atlassian.net/browse/HSEARCH-4355

  • This can apply to properties mapped as e.g. @FullTextField where the corresponding default bridge doesn’t yield a String field

  • This can apply to tenant identifiers as well, see https://hibernate.atlassian.net/browse/HSEARCH-5006

  • I mentioned @Basic properties above, but if the JavaType for e.g. records supports toString/ fromString, we could consider handling @Embeddables as well.

  • We could consider making this adapter explicit instead of implicit with e.g. binder = @IdentifierBinderRef(name = HibernateOrmJavaTypeIdentifierBinder.NAME)

Activity

Details

Assignee

Reporter

Components

Priority

Created November 8, 2023 at 3:57 PM
Updated November 8, 2023 at 3:59 PM

Flag notifications