Joining to association twice using criteria causes: NHibernate.QueryException: duplicate association path

Description

Test case to follow

Environment

None

Activity

Show:
Alex Zaytsev
September 14, 2017, 1:56 AM

Move minor and trivial bugs to 5.0.1 version

Alan Carroll
September 9, 2015, 9:52 PM

We need to join to the same collection twice for reporting queries. Our users want to see the most recent child matching some criteria, and the most recent child matching some other criteria in the same row. This is easy enough to do in SQL, but we can't use that because of the complex criteria we use to build our reports.

GeorgyM
August 5, 2014, 6:29 PM

I'm added criteria alias for unique identification join statement. This makes it possible to declare complex expressions join.

Deviations in the standard behavior of the rest of the functionality I hadn't noticed.

Pull request

Paul White
June 4, 2013, 9:21 AM

It's difficult to show real-world, i'm not at liberty to post my source code or even talk about the nature and relationships of my domain model.

I can tell you that I need to join to the same collection twice because

  • I need to build a dynamic query that flattens a one-to-many into one row (hence criteria api)

  • The query will need a left-outer-join to the collection 0, 1 or perhaps many times depending on user preference

  • Each join is designed to provide one property to be projected on and will be one-to-one with the root entity of the query

  • The criteria API does not support joining to unrelated entities (if it did I would not have this problem)

I am interested in adding the feature but it appears to be a tricky task.

Alex Zaytsev
June 4, 2013, 1:46 AM

Why would you need to join same collection twice? Can you show the real-world scenario?

Duplicate

Assignee

Unassigned

Reporter

Paul White

Labels

Components

Affects versions

Priority

Trivial