Composite ID Criteria queries throw exceptions
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.
Mass-closing issues resolved with no fix-version and untouched for 30 days.
Closed as duplicate of
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.
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.
Don't be so surprised... in ORM the composite-id is only for legacy DB/applications