It is possible that, at some point, users will need to access the ORM session when applying a bridge. For example to execute a query, or to access some other ORM feature. Currently we are very restricting in what we pass to bridge methods: we only pass very specialized parameters that are unlikely to evolve (we can’t really add new concepts because they are so specialized). This makes it impossible to add new parameters to bridge methods without breaking APIs. Maybe we should add an additional, more generic “context” parameter to bridge methods, so that we can, in the future, provide such things as the session context to users. The methods that should accept this parameter are:
- all the bind() methods in bridges (might be at least partly done as part of HSEARCH-3221 Pull Request Sent )
- ValueBridge.toIndexedValue
- PropertyBridge.write
- TypeBridge.write
- IdentifierBridge.toDocumentIdentifier
- IdentifierBridge.fromDocumentIdentifier
- RoutingKeyBridge.toRoutingKey
- FromIndexFieldValueConverter.convert (class added in HSEARCH-3221 Pull Request Sent )
- ToIndexFieldValueConverter.convert (class added in HSEARCH-3223 Pull Request Sent )
Note that in the case of runtime methods, we do not want to only pass a big context parameter wrapping everything, because we might want to optimize instanciation of the context object, for example by instantiating only one per session. In the case of bootstrap methods, we don't really care. See https://github.com/hibernate/hibernate-search-6-poc/commit/8a4fcca27e329e90c9c8be123f7143b6f0961c8c in particular for some drafts |