Skip to content

NRE in linq processing of custom components #2937

@zgabi

Description

@zgabi

With the latest version (5.3.10) of NHibernate I receive a NullReferenceException.
Version 5.3.9 works

.NET 6 RC2

Query:

DataManager.Query<WeatherDataType>(transaction).FirstOrDefault(t => t.Identification.SensorCode == sensorCode)
[Property(0, TypeType = typeof(WeatherDataIdentificationCompositeUserType))]
[Column(1, Name = nameof(WeatherDataIdentification.DateOfSampling), Unique = false, NotNull = false, Index = "WEATHER_DATEOFSAMPLING")]
[Column(2, Name = nameof(WeatherDataIdentification.InternalId), Unique = false, NotNull = false)]
[Column(3, Name = nameof(WeatherDataIdentification.Position) + "_Latitude", Unique = false, NotNull = false)]
[Column(4, Name = nameof(WeatherDataIdentification.Position) + "_Longitude", Unique = false, NotNull = false)]
[Column(5, Name = nameof(WeatherDataIdentification.SensorCode), Unique = false, NotNull = false)]
[Column(6, Name = nameof(WeatherDataIdentification.SensorId), Unique = false, NotNull = false)]
public virtual WeatherDataIdentification Identification...

StackTrace:

System.NullReferenceException: Object reference not set to an instance of an object.
   at NHibernate.Util.ExpressionsHelper.TryGetMappedNullability(ISessionFactoryImplementor sessionFactory, Expression expression, Boolean& nullable)
   at NHibernate.Linq.Visitors.NullableExpressionDetector.IsNullable(MemberExpression memberExpression, BinaryExpression equalityExpression)
   at NHibernate.Linq.Visitors.NullableExpressionDetector.IsNullable(Expression expression, BinaryExpression equalityExpression)
   at NHibernate.Linq.Visitors.HqlGeneratorExpressionVisitor.TranslateEqualityComparison(BinaryExpression expression)
   at NHibernate.Linq.Visitors.HqlGeneratorExpressionVisitor.VisitExpression(Expression expression)
   at NHibernate.Linq.Visitors.QueryModelVisitor.VisitWhereClause(WhereClause whereClause, QueryModel queryModel, Int32 index)
   at Remotion.Linq.QueryModelVisitorBase.VisitBodyClauses(ObservableCollection`1 bodyClauses, QueryModel queryModel)
   at Remotion.Linq.QueryModelVisitorBase.VisitQueryModel(QueryModel queryModel)
   at NHibernate.Linq.Visitors.QueryModelVisitor.Visit()
   at NHibernate.Linq.Visitors.QueryModelVisitor.GenerateHqlQuery(QueryModel queryModel, VisitorParameters parameters, Boolean root, Nullable`1 rootReturnType)
   at NHibernate.Linq.NhLinqExpression.Translate(ISessionFactoryImplementor sessionFactory, Boolean filter)
   at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(IQueryExpression queryExpression, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory)
   at NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow, IDictionary`2 enabledFilters)
   at NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow)
   at NHibernate.Impl.AbstractSessionImpl.CreateQuery(IQueryExpression queryExpression)
   at NHibernate.Linq.DefaultQueryProvider.PrepareQuery(Expression expression, IQuery& query)
   at NHibernate.Linq.DefaultQueryProvider.Execute(Expression expression)
   at NHibernate.Linq.DefaultQueryProvider.Execute[TResult](Expression expression)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions