Missing join in sql when restricting by composite column in criteria query

Description

With a simple Criteria query such as:

s.CreateCriteria<Artist>("a")
.CreateAlias("a.Song", "s")
.Add(Restrictions.Eq("s.Name", "Miss Kiss Kiss Bang"))

NHibernate fails to include the join to Song in the SQL query when Song is a composite column.

GitHub pull request with testcase will be included in the comments.

Environment

None

Activity

Show:

Oskar Berggren 
November 14, 2012 at 12:01 PM

Mass-closing issues resolved with no fix-version and untouched for 30 days.

Alex Zaytsev 
August 2, 2012 at 8:13 AM

Closed as duplicate of

Richard Birkby 
May 30, 2012 at 11:38 AM

This could also be related to (https://nhibernate.jira.com/browse/NH-2033)

Richard Birkby 
May 30, 2012 at 11:03 AM

This issue is likely related to NH1760 (https://nhibernate.jira.com/browse/NH-1760).
In fact, my testcase is just the code included in the comments of NH1760, reformulated into an NHSpecificTest

Richard Birkby 
May 30, 2012 at 11:02 AM

The testcase in the pull request generates the following exception:

NHibernate.Test.NHSpecificTest.NH3171.Fixture.SqlShouldIncludeAliasAsJoinWhenRestrictingByCompositeKeyColumn:
NHibernate.Exceptions.GenericADOException : could not execute query
[ SELECT this_.Song as Song0_0_, this_.Country as Country0_0_, this_.Name as Name0_0_ FROM Artist this_ WHERE s1_.Name = @p0 ]
Name:cp0 - Value:Miss Kiss Kiss Bang
[SQL: SELECT this_.Song as Song0_0_, this_.Country as Country0_0_, this_.Name as Name0_0_ FROM Artist this_ WHERE s1_.Name = @p0]
----> System.Data.SqlClient.SqlException : The multi-part identifier "s1_.Name" could not be bound.

Duplicate

Details

Assignee

Reporter

Labels

Components

Priority

Who's Looking?

Open Who's Looking?
Created May 30, 2012 at 10:53 AM
Updated November 14, 2012 at 12:01 PM
Resolved August 2, 2012 at 8:13 AM
Who's Looking?