我在将 EAR 项目部署到 Wildfly 8 beta1 时遇到问题。该项目使用Hibernate Search 4.5 Alpha 1。索引了一些实体。该项目构建良好,但在部署时引发异常:无法猜测 FieldBridge for id in java.lang.Byte。我尝试禁用所有休眠搜索注释,但仍然出现异常。接缝是一个错误。有什么建议么?
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:169) [wildfly-jpa-8.0.0.Beta1.jar:8.0.0.Beta1]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:117) [wildfly-jpa-8.0.0.Beta1.jar:8.0.0.Beta1]
at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.7.0_25]
at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:463) [wildfly-security-manager-1.0.0.Beta3.jar:1.0.0.Beta3]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:178) [wildfly-jpa-8.0.0.Beta1.jar:8.0.0.Beta1]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.7.0_25]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_25]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_25]
at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.1.1.Final.jar:2.1.1.Final]
Caused by: org.hibernate.search.SearchException: HSEARCH000135: Unable to guess FieldBridge for id in java.lang.Byte
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:324)
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:581)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1837)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:854)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:847)
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:396)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:846)
at org.jboss.as.jpa.hibernate4.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:151) [wildfly-jpa-8.0.0.Beta1.jar:8.0.0.Beta1]
... 8 more
这是重现异常的实体示例:
@Entity
@Table(name = "flow")
public class Flow implements java.io.Serializable {
private static final long serialVersionUID = 3556704047257784867L;
private Byte id;
private String name;
private String description;
public Flow() {
}
public Flow(String name) {
this.name = name;
}
public Flow(String name, String description) {
this.name = name;
this.description = description;
}
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Byte getId() {
return this.id;
}
public void setId(Byte id) {
this.id = id;
}
@Column(name = "name", nullable = false, length = 60)
@NotNull
@Length(max = 60)
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
@Column(name = "description", length = 400)
@Length(max = 400)
public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
}
如果 id 从 Byte 更改为 Short 工作正常。Byte 没有内置的桥接器。也许这是相关的,但主要问题是如果我没有休眠搜索注释,为什么休眠搜索正在寻找桥接?