NHibernate INNER JOIN FETCH is not populating properties

1

I have the following query in HQL:

select
    photoRating
from
    PhotoRating as photoRating
inner join fetch
    photoRating.FormularioRespostaDoUsuario as form
inner join fetch
    form.Trecho as section

And whenever I run it using the ISession.CreateQuery() method, the Trecho property is not populated, it is always null.

I tried to make some changes in the mapping of this property using .Fetch.Select() and .Fetch.Join() , but I did not get any results either.

In the above query I put an INNER JOIN FETCH to the property FormularioRespostaDoUsuario , but even removing this INNER JOIN this property continues to be filled

I imagine that the problem may be related in some way to the mapping of the PhotoRating and FormularioRespostaDoUsuario classes (type of the property of the same name in the query). So I'll post the mapping of these two classes:

public class PhotoRatingMap : ClassMap<PhotoRating>
{
    public PhotoRatingMap()
    {
        Table("PhotoRating");
        Id(x => x.Id)
            .GeneratedBy.Native();
        OptimisticLock.Version();
        Map(x => x.CollaboratorId, "Collaborator_Id");
        Map(x => x.Rating);
        Map(x => x.RatingDate);
        References(x => x.FormularioRespostaDoUsuario)
            .Class(typeof(FormularioRespostaDoUsuario))
            .Not.Nullable()
            .Column("Answer_Id")
            .Fetch.Select();
    }
}

public class FormularioRespostaDoUsuarioMap : ClassMap<FormularioRespostaDoUsuario>
{
    public FormularioRespostaDoUsuarioMap()
    {
        Id(x => x.Id).GeneratedBy.Identity();
        References(x => x.Formulario).Not.Nullable();
        References(x => x.FormularioPergunta).Not.Nullable();
        References(x => x.FormularioPerguntaResposta).Nullable();
        References(x => x.Colaborador).Not.Nullable();
        References(x => x.Product).Nullable();
        Map(x => x.TextoResposta).Length(255).Nullable();
        Map(x => x.DataDaInclusao).Not.Nullable();
        Map(x => x.DataDaExclusao).Nullable();
        Map(x => x.Ativo).Not.Nullable();
        Map(x => x.DentroRange).Not.Nullable();
        References(x => x.Trecho)
            .Nullable()
            .Fetch.Join();
        References(x => x.Pdv).Nullable();
        References(x => x.Coaching).Nullable();
        Map(x => x.DataDaResposta).Nullable();
        Map(x => x.NumeroResposta).Nullable();
        Map ( x => x.Indice ).Nullable();
        Map(x => x.Chave).Nullable();
        Map(x => x.PontuacaoAbsolutaFormularioPergunta).Nullable();
        Map(x => x.PontuacaoFormularioPerguntaResposta).Nullable();
        Map(x => x.PontuacaoRelativaFormularioPergunta).Nullable();
        Map(x => x.PontuacaoCalculada).Nullable();
        HasMany(x => x.PhotoRatings)
            .KeyColumn("Answer_Id")
            .Inverse()
            .Fetch.Select()
            .AsSet();
    }
}

Thank you.

    
asked by anonymous 11.04.2016 / 16:57

0 answers