thanks!
I'll give you some pointers, but please wait for Emmanuel or Hardy to confirm what I say (I'll ping them); also further discussion should continue on the dev-list, so that all developers can comment on this.
If you look into /hibernate-search/src/main/java/org/hibernate/search/engine/DocumentBuilderContainedEntity.java
the method
Code:
private void processContainedIn(Object instance, List<LuceneWork> queue, PropertiesMetadata metadata, SearchFactoryImplementor searchFactoryImplementor) {
...
}
at
DocumentBuilderContainedEntity.javatakes care of delegating the embedded field generation to the DocumentBuilder of the contained-in type;
the simple case is the last one (line 661) where it decides to delegate to the documentbuilder for the type
of the field itself.
There you should change it to read from the impl parameter of the JPA/Hibernate annotation, but there are some requirements:
A)should work also on the collections, not only field (Maps,Arrays,Collections)
B)Search should work also without those annotations being on classpath, so you should not reference directly to the annotation class but use reflection, like what was done for @Id, see the method
Code:
Annotation getIdAnnotation(XProperty member, InitContext context)
in
DocumentBuilderIndexedEntity.java for an example: it checks for JPA presence and loads the annotation by reflection. In your case you will actually need to cast it to the class to read the options, but make sure you don't import it.
C)The "processContainedIn" method is used at runtime for each object added to the index, the final patch should make sure you read the metadata only once at startup.
Another useful pointer:
Contributing to Hibernate Search