Hi All,
I'm trying to index my JournalLogItem with a linkedentity (like a IndexedEmbedded).
I'll try to show my use case with an example:
Code:
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class AbstractEntityModel(){
}
public class AddressEntity extends AbstractEntityModel(){
}
public class CarEntity extends AbstractEntityModel(){
}
@Indexed
@Entity
@ClassBridges({ @ClassBridge(name = "MyCustomFieldBridge", impl = MyCustomFieldBridge.class) })
public class JournalLogItem (){
@IndexEmbedded
private AbstractEntityModel linkedEntity;
private String linkedEntityClassName;
private String linkedEntityId;
@CustomEntityField(classDiscriminatorField = "linkedEntityClassName", entityIdField = "linkedEntityId")
public AbstractEntityModel getLinkedEntity(){
// ?? how can I return the correct entity?
}
}
public class MyCustomFieldBridge implements FieldBridge {
@Override
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
if (value instanceof JournalLogItem ) {
// ?? Can I access to PersistenceContext?
}
}
}
How can I return the correct linked entity?
By a custom ClassBridge can I get the entity from the PersistenceContext? Is there a way to get the actual PersistenceContext from FieldBridge?
Thanks,
dario