public interface TypeBridge extends AutoCloseable
The TypeBridge interface is a more powerful version of ValueBridge
that applies to a whole type instead of a single property,
and can contribute more than one index field, in particular.
| Modifier and Type | Method and Description |
|---|---|
void |
bind(TypeBridgeBindingContext context)
Bind this bridge instance to the given context,
i.e.
|
default void |
close()
Close any resource before the bridge is discarded.
|
void |
write(DocumentElement target,
Object bridgedElement,
TypeBridgeWriteContext context)
Write to fields in the given
DocumentElement,
using the given bridgedElement as input and transforming it as necessary. |
void bind(TypeBridgeBindingContext context)
This method is called exactly once for each bridge instance, before any other method. It allows the bridge to:
write(DocumentElement, Object, TypeBridgeWriteContext) method
using TypeBridgeBindingContext.getIndexSchemaElement().
TypeBridgeBindingContext.getBridgedElement().
write(DocumentElement, Object, TypeBridgeWriteContext) method
using TypeBridgeBindingContext.getDependencies().
write(DocumentElement, Object, TypeBridgeWriteContext) method
using TypeBridgeBindingContext.getBridgedElement().
context - An entry point allowing to perform the operations listed above.void write(DocumentElement target, Object bridgedElement, TypeBridgeWriteContext context)
DocumentElement,
using the given bridgedElement as input and transforming it as necessary.
Writing to the DocumentElement should be done using
IndexFieldReferences retrieved when the
bind(TypeBridgeBindingContext) method was called.
Warning: Reading from bridgedElement should be done with care.
Any read that was not declared in the bind(TypeBridgeBindingContext) method
(by declaring dependencies using TypeBridgeBindingContext.getDependencies()
or (advanced use) creating an accessor using TypeBridgeBindingContext.getBridgedElement())
may lead to out-of-sync indexes,
because Hibernate Search will consider the read property irrelevant to indexing
and will not reindex entities when that property changes.
target - The DocumentElement to write to.bridgedElement - The element this bridge is applied to, from which data should be read.context - A context that can be
extended
to a more useful type, giving access to such things as a Hibernate ORM Session (if using the Hibernate ORM mapper).default void close()
close in interface AutoCloseableCopyright © 2006-2019 Red Hat, Inc. and others. Licensed under the GNU Lesser General Public License (LGPL), version 2.1 or later.