views:

46

answers:

0

Good morning, guys.

I'm with a problem with the query that NHibernate generates. My mapping is like bellow:

public class Matricula
{
       [BelongsTo("IdTurma", NotNull=True)]
       public Turma {get;set;}      
}

public class Turma
{
      [BelongsTo("IdCurso", NotNull=True)]
      public Curso {get;set;}
}

public class Curso
{
       [PrimaryKey("IdCurso", Generator=PrimaryKeyType.Identity)]
       public int IdCurso{get;set;}
}

The problem is: The Nh generates the query with left where should be inner. Between Matricula and Turma they makes inner, but between Turma and Curso they makes left outer. What's problem? What's wrong?

My query:

SELECT  this_.IdMatricula as IdMatric1_122_14_, 
  this_.IdTurma as IdTurma122_14_, 
  this_.IdUsuario as IdUsuario122_14_, 
  turma3_.IdTurma as IdTurma25_0_, 
  turma3_.idTurmaStatus as idTurmaS2_25_0_,   
  turma3_.IdCurso as IdCurso25_0_,   
  curso4_.IdCurso as IdCurso31_1_, 
  curso4_.idStatus as idStatus31_1_, 
  curso4_.IdTipoCurso as IdTipoC10_31_1_, 
  curso4_.IdOrganization as IdOrgan11_31_1_,   
  statuscurs5_.idStatus as idStatus54_2_, 
  statuscurs5_.strStatus as strStatus54_2_, 
  tipocurso6_.strDescricao as strDescr2_125_3_, 
  padraocomu7_.strNmPadrao as strNmPad2_103_4_, 
  organizati8_.Id_Organization as Id1_87_5_, 
  organizati8_.strTitle as strTitle87_5_,
  cursoprese9_.IdCurso as IdCurso6_6_, 
  turmastatu10_.idTurmaStatus as idTurmaS1_91_7_,   
  usuario1_.IdUsuario as IdUsuario116_10_, 
  organizaca14_.idOrganizacao as idOrgani1_83_11_, 
  cargo15_.idCargo as idCargo7_12_,
  matriculas16_.idMatriculaStatus as idMatric1_15_13_
   FROM tracking.matriculas this_ 
 inner join cursos.turmas turma3_ on this_.IdTurma=turma3_.IdTurma 
 left outer join schemadbo.cursos curso4_ on turma3_.IdCurso=curso4_.IdCurso 
 left outer join schemadbo.status statuscurs5_ on curso4_.idStatus=statuscurs5_.idStatus 
 left outer join schemadbo.tipos tipocurso6_ on curso4_.IdTipoCurso=tipocurso6_.IdTipoCurso 
 left outer join schemadbo.PadraoComunicacao padraocomu7_ on curso4_.IdPadraoComunicacao=padraocomu7_.IdPadrao 
 left outer join schemadbo.lms_cp_organizations organizati8_ on curso4_.IdOrganization=organizati8_.Id_Organization 
 left outer join schemadbo.CursosPresenciais cursoprese9_ on curso4_.IdCurso=cursoprese9_.IdCurso 
 left outer join schemadbo.turmasstatus turmastatu10_ on turma3_.idTurmaStatus=turmastatu10_.idTurmaStatus 
 left outer join schemadbo.turmaspresenciais turmaprese11_ on turma3_.IdTurma=turmaprese11_.idTurma 
 inner join schemadbo.matriculasresumo matricular12_ on this_.IdMatricula=matricular12_.IdMatricula 
 inner join schemadbo.usuarios usuario1_ on this_.IdUsuario=usuario1_.IdUsuario 
 left outer join schemadbo.Organizacoes organizaca14_ on usuario1_.idOrganizacao=organizaca14_.idOrganizacao 
 left outer join schemadbo.cargos cargo15_ on usuario1_.idCargo=cargo15_.idCargo 
 inner join schemadbo.matriculasstatus matriculas16_ on this_.idMatriculaStatus=matriculas16_.idMatriculaStatus 
  WHERE this_.IdTurma = @p0