0

什么可能导致休眠尝试解析包路径并且在这样做时也会失败:

Exception in thread "Timer-9" org.hibernate.QueryException: could not resolve property: codeto of: citylist_AUD [select new list(ee, e) from citylist_AUD ee, ee.codeto.wes.Citylist_AUD e where ee.originalId.citylist_id = e.originalId.id and ee.originalId.Road_id = :Road_id and e.originalId.REV.id = (select max(e2.originalId.REV.id) from ee.codeto.wes.Citylist_AUD e2 where e2.originalId.REV.id <= :revision and e.originalId.id = e2.originalId.id) and ee.originalId.REV.id = (select max(ee2.originalId.REV.id) from road_city_AUD ee2 where ee2.originalId.REV.id <= :revision and ee.originalId.Road_id = ee2.originalId.Road_id and ee.originalId.citylist_id = ee2.originalId.citylist_id) and ee.REVTYPE != :delrevisiontype and e.REVTYPE != :delrevisiontype]
at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:81)
at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:75)
at org.hibernate.persister.entity.AbstractEntityPersister.toType(AbstractEntityPersister.java:1465)
at org.hibernate.hql.ast.tree.FromElementType.getPropertyType(FromElementType.java:315)
at org.hibernate.hql.ast.tree.FromElement.getPropertyType(FromElement.java:487)
at org.hibernate.hql.ast.tree.DotNode.getDataType(DotNode.java:611)
at org.hibernate.hql.ast.tree.DotNode.prepareLhs(DotNode.java:263)
at org.hibernate.hql.ast.tree.DotNode.resolve(DotNode.java:210)
at org.hibernate.hql.ast.tree.FromReferenceNode.recursiveResolve(FromReferenceNode.java:101)
at org.hibernate.hql.ast.tree.FromReferenceNode.recursiveResolve(FromReferenceNode.java:94)
at org.hibernate.hql.ast.tree.FromReferenceNode.recursiveResolve(FromReferenceNode.java:94)
at org.hibernate.hql.ast.tree.FromReferenceNode.recursiveResolve(FromReferenceNode.java:94)
at org.hibernate.hql.ast.tree.FromReferenceNode.recursiveResolve(FromReferenceNode.java:94)
at org.hibernate.hql.ast.tree.FromElementFactory.evaluateFromElementPath(FromElementFactory.java:172)
at org.hibernate.hql.ast.tree.FromElementFactory.createFromElementInSubselect(FromElementFactory.java:134)
at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:107)
at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:93)
at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:327)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3441)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3325)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:733)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:584)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4479)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3947)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2047)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1975)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1972)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1972)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1972)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:831)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:617)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:301)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:244)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:256)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:187)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:138)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:124)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1770)
at org.hibernate.envers.entities.mapper.relation.query.TwoEntityQueryGenerator.getQuery(TwoEntityQueryGenerator.java:128)
at org.hibernate.envers.entities.mapper.relation.lazy.initializor.AbstractCollectionInitializor.initialize(AbstractCollectionInitializor.java:62)
at org.hibernate.envers.entities.mapper.relation.lazy.proxy.CollectionProxy.checkInit(CollectionProxy.java:50)
at org.hibernate.envers.entities.mapper.relation.lazy.proxy.CollectionProxy.iterator(CollectionProxy.java:70)
at ee.codeto.wes.Helper.getListSum(Helper.java:329)

我正在使用休眠 3.6.9

一切正常,直到我为两个被审计实体之间的多对多关系引入审计。基本上是 Road.java:

@Audited
@Entity
@Table(name = "ROAD")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Road {
    ...
    @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "ROAD_CITYLIST", joinColumns = { @JoinColumn(name = "ROAD_ID") }, inverseJoinColumns = { @JoinColumn(name = "CITYLIST_ID") })
    @Fetch(FetchMode.SUBSELECT)
    @Cache(usage = CacheConcurrencyStrategy.NONE)
    private Set<CityList> citylists;
    ...
}

我用同样的逻辑做了一个类似的小测试并且成功了。我真的很感激任何帮助或朝着正确方向轻推。如果需要其他信息,只需命名,我可以提供。

4

1 回答 1

0

回答我自己的问题:

该错误与 3.6 的休眠环境有关,在某些情况下,从爱沙尼亚域名派生的包名称(例如 ee.codeto.foo)会遇到问题。这是因为在构建查询期间的某个时候,hibernate envers 使用“ee”作为别名,并且如果使用带有包的完整类名(现在总是),那么 hibernate 认为包名中的下一部分在“ee”之后" 是列名。

在更高版本的休眠中,这个问题得到了解决。可能不是因为爱沙尼亚域名,而是因为更好的别名使用。使用“ee_ ”代替“ee”。因此,当您不幸拥有一个以“ee _”作为包名称的第一部分的包并且碰巧使用休眠环境并且碰巧使用多对多映射并且碰巧遇到hibernet的不幸情况时尝试对包使用完整的类名,那么您可能会受到此错误的影响。

于 2013-11-15T14:46:04.613 回答