I do not apply lazy load because in any cases the inner work and in others not work. Do you never looked the querys that the NH generates?
2010/4/16 Markus Zywitza <[email protected]> > Did you try with a lazy loaded collection already? > > -Markus > > 2010/4/15 Diego Dias <[email protected]> > > I did a test: >> >> ICriteria c = session >> .CreateCriteria<Matricula>(); >> >> c.SetFirstResult(0) >> .SetMaxResults(10); >> >> ICriteria c2 = CriteriaTransformer.Clone(c); >> var count = >> c2.SetProjection(Projections.RowCount()) >> .UniqueResult<int>(); >> >> return c.List<Matricula>(); >> >> The query generates is: >> >> SELECT top 10 this_.IdMatricula as IdMatric1_38_17_ >> FROM tracking.matriculas this_ >> inner join 1.turmas turma2_ on this_.IdTurma=turma2_.IdTurma >> left outer join 1.cursos curso3_ on turma2_.IdCurso=curso3_.IdCurso >> left outer join 1.status statuscurs4_ on >> curso3_.idStatus=statuscurs4_.idStatus >> left outer join 1.tipos tipocurso5_ on >> curso3_.IdTipoCurso=tipocurso5_.IdTipoCurso >> left outer join 1.PadraoComunicacao padraocomu6_ on >> curso3_.IdPadraoComunicacao=padraocomu6_.IdPadrao >> left outer join 2.lms_cp_organizations organizati7_ on >> curso3_.IdOrganization=organizati7_.Id_Organization >> left outer join 1.CursosPresenciais cursoprese8_ on >> curso3_.IdCurso=cursoprese8_.IdCurso >> left outer join 1.turmasstatus turmastatu9_ on >> turma2_.idTurmaStatus=turmastatu9_.idTurmaStatus >> left outer join 1.TurmasPresenciais turmaprese10_ on >> turma2_.IdTurma=turmaprese10_.idTurma >> inner join 3.matriculasresumo matricular11_ on >> this_.IdMatricula=matricular11_.IdMatricula >> inner join 4.Usuarios usuario12_ on >> this_.IdUsuario=usuario12_.IdUsuario >> left outer join 5.Usuarios usuario12_1_ on >> usuario12_.IdUsuario=usuario12_1_.idUsuario >> left outer join 6.Organizacoes organizaca13_ on >> usuario12_.idOrganizacao=organizaca13_.idOrganizacao >> left outer join 6.Cargos cargo14_ on >> usuario12_.idCargo=cargo14_.idCargo >> left outer join 5.TiposColaboradores tipocolabo15_ on >> usuario12_1_.idTipoColaborador=tipocolabo15_.IdTipo >> left outer join 5.NiveisHierarquicos nivelhiera16_ on >> usuario12_1_.idNivelHierarquico=nivelhiera16_.IdNivel >> left outer join 5.EstadosCivis estadocivi17_ on >> usuario12_1_.idEstadoCivil=estadocivi17_.IdEstadoCivil >> inner join 3.matriculasstatus matriculas18_ on >> this_.idMatriculaStatus=matriculas18_.idMatriculaStatus >> >> I noticed that the "left outer join" are add when the object is a >> child of a child of the object parrent. >> I have Matricula that has Turma that has Curso. Then between Matricula >> and Turma the NH add inner join but between Turma and Curso the NH add >> left outer join. >> >> This is default? something's wrong with my mapping/model? >> >> The query c2 is only test I do not use it. >> >> On 13 abr, 14:52, Diego Dias <[email protected]> wrote: >> > My criteria have this: >> > { >> > IdTurma = -99 >> > Usuario.NomeCompleto asc >> > >> > } >> > >> > Being that I create my criteria by Matricula >> > >> > 2010/4/13 Markus Zywitza <[email protected]> >> > >> > >> > >> > > Can you share the ICriteria query code then? >> > >> > > -Markus >> > >> > > 2010/4/13 Diego Dias <[email protected]> >> > >> > >> I use ICriteria and is query I get in sql profile. >> > >> > >> 2010/4/13 Markus Zywitza <[email protected]> >> > >> > >> What is the query (in HQL or LINQ)? >> > >> > >>> -Markus >> > >> > >>> 2010/4/13 Diego Dias <[email protected]> >> > >> > >>>> 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 >> > >>>> -- >> > >>>> You received this message because you are subscribed to the Google >> > >>>> Groups "Castle Project Users" group. >> > >>>> To post to this group, send email to >> > >>>> [email protected]. >> > >>>> To unsubscribe from this group, send email to >> > >>>> [email protected]<castle-project-users%[email protected]><castle-project-users%2Bun >> [email protected]> >> > >>>> . >> > >>>> For more options, visit this group at >> > >>>>http://groups.google.com/group/castle-project-users?hl=en. >> > >> > >>> -- >> > >>> You received this message because you are subscribed to the Google >> Groups >> > >>> "Castle Project Users" group. >> > >>> To post to this group, send email to >> > >>> [email protected]. >> > >>> To unsubscribe from this group, send email to >> > >>> [email protected]<castle-project-users%[email protected]><castle-project-users%2Bun >> [email protected]> >> > >>> . >> > >>> For more options, visit this group at >> > >>>http://groups.google.com/group/castle-project-users?hl=en. >> > >> > >> -- >> > >> You received this message because you are subscribed to the Google >> Groups >> > >> "Castle Project Users" group. >> > >> To post to this group, send email to >> > >> [email protected]. >> > >> To unsubscribe from this group, send email to >> > >> [email protected]<castle-project-users%[email protected]><castle-project-users%2Bun >> [email protected]> >> > >> . >> > >> For more options, visit this group at >> > >>http://groups.google.com/group/castle-project-users?hl=en. >> > >> > > -- >> > > You received this message because you are subscribed to the Google >> Groups >> > > "Castle Project Users" group. >> > > To post to this group, send email to >> [email protected] >> > > . >> > > To unsubscribe from this group, send email to >> > > [email protected]<castle-project-users%[email protected]><castle-project-users%2Bun >> [email protected]> >> > > . >> > > For more options, visit this group at >> > >http://groups.google.com/group/castle-project-users?hl=en. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Castle Project Users" group. >> To post to this group, send email to >> [email protected]. >> To unsubscribe from this group, send email to >> [email protected]<castle-project-users%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/castle-project-users?hl=en. >> >> > -- > You received this message because you are subscribed to the Google Groups > "Castle Project Users" group. > To post to this group, send email to [email protected] > . > To unsubscribe from this group, send email to > [email protected]<castle-project-users%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/castle-project-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.
