Skip to content

InvalidWithClauseException when join polymorphic entity #2580

Closed
@chrwell

Description

@chrwell

Situation

Updating NHibernate from 5.2.7 to 5.3.3 we ran into issues with queries operating on inheritance hierarchies. We join inherited entities and run operators such as distincts or simple selects. Analyzing the exception with clause can only reference columns in the driving table we soon came to find the cause being the HqlSqlWalker and its WithClauseVisitor. There the names of aliases are compared and if different, an exception is thrown.

Comparison with Hibernate

After some research we found this to be an issue in Hibernate as well: https://hibernate.atlassian.net/browse/HHH-11383. It was fixed here: hibernate/hibernate-orm@5ac46eb.

We use NHibernate as our ORM for large-scale projects and ensure compability with a test coverage of 20K+ tests (hence we discovered this issue quickly). For testing purposes we disabled the exception (as in Hibernate) and ran our queries, which then work smoothly.

Request

Is it possible to adapt the change from Hibernate to NHibernate and disable the check of alias names in this case and consequently not throwing the exception?

On a side note: perhaps this became a problem in the first place after NHibernate release 5.3.0 and this change #2078

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions