INNER JOIN FETCH Nhibernate is not filling properties

Asked

Viewed 269 times

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 execute it using the method ISession.CreateQuery() the property Trecho is not filled in, is always null.

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

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

I imagine the problem may be related in some way to class mapping PhotoRating and FormularioRespostaDoUsuario (type of the same name property in the query). So I will also 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.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.