我在POJO中有以下配置:
@Field(index = Index.NO, store = Store.YES)
private byte[] file;
当我启动我的Apps容器时,我得到以下异常:
引起:org.hibernate.search.SearchException:无法猜测FieldBridge的文件 在org.hibernate.search.bridge.BridgeFactory.guessType(BridgeFactory.java:249) 在org.hibernate.search.engine.AbstractDocumentBuilder.bindFieldAnnotation(AbstractDocumentBuilder.java:707) 在org.hibernate.search.engine.AbstractDocumentBuilder.checkForField(AbstractDocumentBuilder.java:568) at org.hibernate.search.engine.AbstractDocumentBuilder.initializeMemberLevelAnnotations(AbstractDocumentBuilder.java:436) 在org.hibernate.search.engine.AbstractDocumentBuilder.initializeClass(AbstractDocumentBuilder.java:383) 在org.hibernate.search.engine.AbstractDocumentBuilder.checkForIndexedEmbedded(AbstractDocumentBuilder.java:631) at org.hibernate.search.engine.AbstractDocumentBuilder.initializeMemberLevelAnnotations(AbstractDocumentBuilder.java:440) 在org.hibernate.search.engine.AbstractDocumentBuilder.initializeClass(AbstractDocumentBuilder.java:383) 在org.hibernate.search.engine.AbstractDocumentBuilder。(AbstractDocumentBuilder.java:134) 在org.hibernate.search.engine.DocumentBuilderIndexedEntity。(DocumentBuilderIndexedEntity.java:178) 在org.hibernate.search.spi.SearchFactoryBuilder.initDocumentBuilders(SearchFactoryBuilder.java:375) 在org.hibernate.search.spi.SearchFactoryBuilder.buildNewSearchFactory(SearchFactoryBuilder.java:262) 在org.hibernate.search.spi.SearchFactoryBuilder.buildSearchFactory(SearchFactoryBuilder.java:144) 在org.hibernate.search.event.FullTextIndexEventListener.initialize(FullTextIndexEventListener.java:151) 在org.hibernate.event.EventListeners $ 1.processListener(EventListeners.java:198) 在org.hibernate.event.EventListeners.processListeners(EventListeners.java:181) 在org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:194) ......还有41个
答案 0 :(得分:4)
您需要field bridge。
例如:
@Field(index = Index.NO, store = Store.YES)
@FieldBridge(impl = MyFieldBridge.class)
private byte[] file;
//The file bridge
public class MyFieldBridge implements StringBridge {
@Override
public String objectToString(final Object object) {
byte[] file = (byte[]) object;
return MagicFileUtil.getTextContent(file)
}
}