NullReference Exception in NH 2.1

4 views
Skip to first unread message

nicco80

unread,
Aug 6, 2009, 9:00:16 AM8/6/09
to nhusers
Hi,
when performing a linq.select on a quite nested query i get an
adoexception
"could not execute query" with a NullReferenceException as an
innerexception -
has anybody seen this stacktrace already?

(innerexception):
at NHibernate.Param.NamedParameterSpecification.Bind(IDbCommand
statement, QueryParameters qp, ISessionImplementor session, Int32
position)
at NHibernate.Hql.Ast.ANTLR.Loader.QueryLoader.BindParameterValues
(IDbCommand statement, QueryParameters queryParameters, Int32
startIndex, ISessionImplementor session)
at NHibernate.Loader.Loader.PrepareQueryCommand(QueryParameters
queryParameters, Boolean scroll, ISessionImplementor session)
at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session,
QueryParameters queryParameters, Boolean returnProxies)
at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections
(ISessionImplementor session, QueryParameters queryParameters, Boolean
returnProxies)
at NHibernate.Loader.Loader.DoList(ISessionImplementor session,
QueryParameters queryParameters)

thanks,
regards nico

Tuna Toksoz

unread,
Aug 6, 2009, 9:03:48 AM8/6/09
to nhu...@googlegroups.com
Nested queries are not really supported.

nicco80

unread,
Aug 6, 2009, 10:08:34 AM8/6/09
to nhusers
Sorry for being imprecise on that.
i do not perform a nested query but a query on quite nested mapping.

this used to work correctly with nh1.2

i have a class hierarchy, performing the following call
session.Delete("from ObjectData o where o.DataOrigin = :DataOrigin",
object.Id,
NHibernate.NHibernateUtil.Int64);

will trigger the exception - i already posted the inner exception, so
here goes the adoexception carrying the inner nullreferenceexception
thanks for any ideas on this
regards

could not execute query
[ select objectdata0_.Id as Id2_, objectdata0_.CheckTime as
CheckTime2_, objectdata0_.ResponseTime as Response3_2_,
objectdata0_.StatusFlag as StatusFlag2_, objectdata0_.Status as
Status2_, objectdata0_.DataOrigin as DataOrigin2_,
objectdata0_.CheckExceptionMessage as CheckExc7_2_,
objectdata0_2_.AvailableBytes as Availabl2_27_,
objectdata0_2_.TotalBytes as TotalBytes27_, objectdata0_2_.UsedBytes
as UsedBytes27_, objectdata0_3_.Result as Result28_,
objectdata0_3_.RecordsAffected as RecordsA3_28_,
objectdata0_3_.RowsSelected as RowsSele4_28_,
objectdata0_4_.ErrorStreamContent as ErrorStr2_31_,
objectdata0_4_.OutputStreamContent as OutputSt3_31_,
objectdata0_4_.ExitCode as ExitCode31_, objectdata0_5_.HttpStatusCode
as HttpStat2_36_, objectdata0_5_.HttpStatusDescription as
HttpStat3_36_, objectdata0_5_.ContentType as ContentT4_36_,
objectdata0_5_.ContentEncoding as ContentE5_36_,
objectdata0_5_.ContentLength as ContentL6_36_,
objectdata0_5_.ResponseCharacterSet as Response7_36_,
objectdata0_5_.Checksum as Checksum36_, objectdata0_5_.ContentBytes as
ContentB9_36_, objectdata0_6_.RemoteIp as RemoteIp37_,
objectdata0_6_.RemotePort as RemotePort37_, objectdata0_7_.AverageTime
as AverageT2_38_, objectdata0_7_.StandardDeviation as Standard3_38_,
objectdata0_7_.MinimumTime as MinimumT4_38_,
objectdata0_7_.MaximumTime as MaximumT5_38_,
objectdata0_7_.AnswerPackages as AnswerPa6_38_,
objectdata0_7_.LostPackages as LostPack7_38_,
objectdata0_8_.ConnectionOk as Connecti2_40_,
objectdata0_8_.DnsResponseCode as DnsRespo3_40_,
objectdata0_8_.Records as Records40_, case when
objectdata0_5_.NetworkobjectData_Id is not null then 5 when
objectdata0_6_.NetworkobjectData_Id is not null then 6 when
objectdata0_7_.NetworkobjectData_Id is not null then 7 when
objectdata0_8_.NetworkobjectData_Id is not null then 8 when
objectdata0_1_.objectData_Id is not null then 1 when
objectdata0_2_.objectData_Id is not null then 2 when
objectdata0_3_.objectData_Id is not null then 3 when
objectdata0_4_.objectData_Id is not null then 4 when objectdata0_.Id
is not null then 0 end as clazz_ from objectData objectdata0_ left
outer join NetworkobjectData objectdata0_1_ on
objectdata0_.Id=objectdata0_1_.objectData_Id left outer join
DiskobjectData objectdata0_2_ on
objectdata0_.Id=objectdata0_2_.objectData_Id left outer join
DatabaseobjectData objectdata0_3_ on
objectdata0_.Id=objectdata0_3_.objectData_Id left outer join
ExecobjectData objectdata0_4_ on
objectdata0_.Id=objectdata0_4_.objectData_Id left outer join
HttpobjectData objectdata0_5_ on
objectdata0_.Id=objectdata0_5_.NetworkobjectData_Id left outer join
SocketobjectData objectdata0_6_ on
objectdata0_.Id=objectdata0_6_.NetworkobjectData_Id left outer join
ICMPobjectData objectdata0_7_ on
objectdata0_.Id=objectdata0_7_.NetworkobjectData_Id left outer join
DNSobjectData objectdata0_8_ on
objectdata0_.Id=objectdata0_8_.NetworkobjectData_Id where
objectdata0_.DataOrigin=? ]


On Aug 6, 3:03 pm, Tuna Toksoz <tehl...@gmail.com> wrote:
> Nested queries are not really supported.
>
> Tuna Toksöz
> Eternal sunshine of the open source mind.
>
> http://devlicio.us/blogs/tuna_toksozhttp://tunatoksoz.comhttp://twitter.com/tehlike

Tuna Toksoz

unread,
Aug 6, 2009, 10:34:19 AM8/6/09
to nhu...@googlegroups.com
I thought you worked with linq.

A test case with mapping etc is appreciated.

nicco80

unread,
Aug 14, 2009, 5:16:20 AM8/14/09
to nhusers
I posted a testcase to the nhcontrib group.
http://groups.google.com/group/nhcdevs/browse_thread/thread/3c0c1bd77d27f2fd

Things fail when calling
session.Delete("from Foo foo where foo.ModuleId = :Id", m.ModuleId,
NHibernate.NHibernateUtil.Int32);
with stacktrace (InnerException!)
at NHibernate.Param.NamedParameterSpecification.Bind(IDbCommand
statement, QueryParameters qp, ISessionImplementor session, Int32
position)
at NHibernate.Hql.Ast.ANTLR.Loader.QueryLoader.BindParameterValues
(IDbCommand statement, QueryParameters queryParameters, Int32
startIndex, ISessionImplementor session)
at NHibernate.Loader.Loader.PrepareQueryCommand(QueryParameters
queryParameters, Boolean scroll, ISessionImplementor session)
at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session,
QueryParameters queryParameters, Boolean returnProxies)
at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections
(ISessionImplementor session, QueryParameters queryParameters, Boolean
returnProxies)
at NHibernate.Loader.Loader.DoList(ISessionImplementor session,
QueryParameters queryParameters)

I'd be glad if anyone could help me on that.
Regards Nico

Fabio Maulo

unread,
Aug 14, 2009, 9:13:27 AM8/14/09
to nhu...@googlegroups.com
session.Delete does not work with named parameters (as the exception is saying)
You should use positional parameter.
session.Delete("from Foo foo where foo.ModuleId = ?", m.ModuleId,
NHibernate.NHibernateUtil.Int32);



2009/8/14 nicco80 <nicol...@poczta.onet.pl>



--
Fabio Maulo
Reply all
Reply to author
Forward
0 new messages