4

I'm trying to use Hibernate Search (4.4.0) in a project with a large object model (>200 entities). Of these, I want to index only a few entities; currently just a single one. I added the @Indexed, @DocumentId and @Field annotations as appropriate to the entity.

However, when I deploy my artifact and start the application server, I'm getting an error message "HSEARCH000135: Unable to guess FieldBridge for [field] in [type]" for the primary key of an entity that is in the same persistence unit, but completely unrelated to the indexed entity.

I don't want to specify custom fieldbridges for entity primary keys that I don't intend to index, as this would take a long time to implement on the complete object model.

My questions are: why is this happening? Is there any way around this?

For reference, the complete stacktrace is given below:

org.hibernate.search.SearchException: HSEARCH000135: Unable to guess FieldBridge for <field> in <type>
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:100)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_21]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_21]
    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_21]
    at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Caused by: org.hibernate.search.SearchException: HSEARCH000135: Unable to guess FieldBridge for <field> in <type>
    at org.hibernate.search.bridge.impl.BridgeFactory.guessType(BridgeFactory.java:432)
    at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.checkDocumentId(AnnotationMetadataProvider.java:159)
    at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.initializeMemberLevelAnnotations(AnnotationMetadataProvider.java:625)
    at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.initializeClass(AnnotationMetadataProvider.java:338)
    at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.getTypeMetadataFor(AnnotationMetadataProvider.java:118)
    at org.hibernate.search.engine.spi.AbstractDocumentBuilder.<init>(AbstractDocumentBuilder.java:100)
    at org.hibernate.search.engine.spi.DocumentBuilderContainedEntity.<init>(DocumentBuilderContainedEntity.java:62)
    at org.hibernate.search.spi.SearchFactoryBuilder.initDocumentBuilders(SearchFactoryBuilder.java:342)
    at org.hibernate.search.spi.SearchFactoryBuilder.buildNewSearchFactory(SearchFactoryBuilder.java:217)
    at org.hibernate.search.spi.SearchFactoryBuilder.buildSearchFactory(SearchFactoryBuilder.java:141)
    at org.hibernate.search.hcore.impl.HibernateSearchSessionFactoryObserver.sessionFactoryCreated(HibernateSearchSessionFactoryObserver.java:74)
    at org.hibernate.internal.SessionFactoryObserverChain.sessionFactoryCreated(SessionFactoryObserverChain.java:52)
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:558)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1746)
    at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94)
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905)
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890)
    at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:197)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$500(PersistenceUnitServiceImpl.java:57)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:96)
    ... 4 more
Rubrick
  • 308
  • 5
  • 13
  • 1
    Hi, could you show the mapping of the entity which is failing the boot? This is (obviously) not supposed to happen so I need to figure out how you're triggering it. Ideally if you could describe it on a freshly created JIRA issue on https://hibernate.atlassian.net/browse/HSEARCH – Sanne Nov 01 '13 at 14:51
  • It's caused by primary keys of type java.sql.Timestamp and composite keys that are composed of @ManyToOne relations to other entities. If that doesn't help you to reproduce the problem I can try to set up a small project that shows what is happening. – Rubrick Nov 01 '13 at 15:23
  • Thanks that is enough, I already see what's wrong. Created https://hibernate.atlassian.net/browse/HSEARCH-1447 – Sanne Nov 01 '13 at 15:46
  • Actually even though I suspected something, I can't reproduce it. I would love to see the mapping of the failing entity and its primary key, could you please add these as comments(or attachment) on the JIRA? – Sanne Nov 02 '13 at 16:21
  • I created a sample project that shows the failure: https://github.com/robbertbrak/hsearch-1447. – Rubrick Nov 09 '13 at 09:35

1 Answers1

0

So this was a bug (https://hibernate.atlassian.net/browse/HSEARCH-1447) that has been fixed for a long time now. The solution is to use at least version 4.4.3.Final of Hibernate Search.

Rubrick
  • 308
  • 5
  • 13