Multiple joins on Oracle 10g with NHibernate

Translated from French. Read the original

A few posts mention a bug that occurs with Oracle 10g and NHibernate when performing multiple joins.

You then get an “ORA-00904” error. Once you read the generated SQL, you realize that the joins following a comma cannot use the aliases declared in the Select.

left outer join "City" city2_ on address1_.City_id=city2_.Id, "Country" country6_
left outer join Provider_Specialities specialiti3_ on provider0_.Id=specialiti3_.Provider_id

So using provider0_.Id in the second join is invalidated by the “,” of the first join.
The offending code is located in the Oracle10gDialect.cs file in NHibernate.Dialect. Here it is:

public class Oracle10gDialect : Oracle9iDialect
{
    public override JoinFragment CreateOuterJoinFragment()
    {
        return new ANSIJoinFragment();
    }
}

The simplest workaround is to change the dialect of your SessionFactory from Oracle10 to Oracle9.

All articles