Composite ID Criteria queries throw exceptions

Description

When using a composite ID in a Criteria query, NHibernate fails to include a JOIN in the SQL query, but still adds the projection into the query. This results in an error from the database. In the case of SQL Server, the error is:

System.Data.SqlClient.SqlException: The multi-part identifier "e1x1_.Foo" could not be bound.

I will attach a patch containing a unit test to be included in NHibernate.Test.

Surprisingly, given how simple the testcase is, this issue does not appear to be unique to NHibernate 3. Previous versions have also exhibited this bug.

Environment

None

Attachments

1

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

Fabio Maulo 
December 23, 2010 at 3:13 PM

well...
when I have made that, I have considered the DB as part of the application so the re-factor of the application includes the re-factor of DB.
btw, OK this is not the place for such discussions.

Richard Birkby 
December 23, 2010 at 8:18 AM

I'm not surprised that people use NHibernate with legacy databases. It's much more capable than EF in this respect.

In fact, I discovered this while working on porting a large, legacy system from Oracle to SQL Server (which has now been deployed successfully, moving about a thousand sprocs into a C# database-agnostic domain layer).

I'm sure many other people have used NH for exactly the same task.

Fabio Maulo 
December 23, 2010 at 8:04 AM

Don't be so surprised... in ORM the composite-id is only for legacy DB/applications

Duplicate

Details

Assignee

Reporter

Components

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created December 23, 2010 at 7:31 AM
Updated November 14, 2012 at 12:01 PM
Resolved August 2, 2012 at 8:13 AM
Who's Looking?