1

我正在寻求帮助以解决从 JBoss4 迁移到 JBoss5 时出现的问题。Hibernate 对 VFS 的支持似乎存在问题(在 JBoss5 中引入)。

出于模块化原因,多个工件具有持久性单元 (pu) 声明。在部署期间,它们都被合并到一个类似的声明中

Processing PersistenceUnitInfo [
    name: pu
    persistence provider classname: null
    classloader: org.jboss.web.tomcat.service.WebCtxLoader$ENCLoader@7a74fa
    Temporary classloader: org.springframework.instrument.classloading.SimpleThrowawayClassLoader@432f0a33
    excludeUnlistedClasses: false
    JTA datasource: com.xyz.jdbc.datasource.DelegatingDataSource@4546bcba
    Non JTA datasource: com.xyz.jdbc.datasource.DelegatingDataSource@4546bcba
    Transaction type: JTA
    PU root URL: vfszip:/<path>/<jar>/
    Jar files URLs [
        vfsfile:/<path>/<exploded jar>/
        vfsfile:/<path>/<exploded jar>/
        vfsfile:/<path>/<exploded jar>/
        vfszip:/<path>/<jar>/
        vfszip:/<path>/<jar>/
        vfszip:/<path>/<jar>/]
    Managed classes names []
    Mapping files names []
    Properties []

启用调试时,我们可以看到爆炸的 jar 未扫描注释

[org.hibernate.ejb.packaging.AbstractJarVisitor] Searching mapped entities in jar/par: vfsfile:/<path>/<exploded jar>/
[org.hibernate.ejb.packaging.AbstractJarVisitor] Searching mapped entities in jar/par: vfsfile:/<path>/<exploded jar>/

而按预期扫描的紧凑 JAR

[org.hibernate.ejb.packaging.AbstractJarVisitor] Searching mapped entities in jar/par: vfszip:/<path>/<jar>/
[org.hibernate.ejb.packaging.AbstractJarVisitor] Filtering: com.xyz.batch.configuration.internal.impl.JobMetadataDocumentImpl$1$JobList
...

导致查询未找到的实体时出现 QuerySyntaxException

org.hibernate.hql.ast.QuerySyntaxException: <EntityName> is not mapped 
4

1 回答 1

1

根据 Red Hat 支持,无法对已分解的 JAR 进行扫描。有两种解决方案:

  • 使用 Compact JAR 并按预期进行扫描
  • 使用 Exploded JAR 并在持久化单元中使用 < class /> 标记声明所有 @Entity。
于 2011-11-02T08:55:19.337 回答