-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: NullReferenceException from GenericPersistentBag
PostPosted: Wed Jan 27, 2010 6:00 pm 
Expert
Expert

Joined: Fri Oct 28, 2005 5:38 pm
Posts: 390
Location: Cedarburg, WI
We're trying to upgrade from NH 2.0.1 to NH 2.1.2. When we access an uninitialized collection mapped as a bag, we get a NullReferenceException from GenericPersistentBag.GetEnumerator().

Looking at the code, if the constructor just taking a session is called, it never initializes the private field gbag. It looks like almost all the other classes in NHibernate\Collection and NHibernate\Collection\Generic have this kind of problem.

I worked around it by modifying the constructor from
Code:
public PersistentGenericBag(ISessionImplementor session) : base(session) {}

to
Code:
public PersistentGenericBag(ISessionImplementor session) : this(session, new List<T>()) {}


GenericPersistentBag.cs (and probably the other collection classes) have changed since NH 2.0.1, but the older code still has similar problems. Apparently something changed in NH so that these constructors are now getting called when they weren't before?

Hasn't anyone else seen this problem? My confidence in NH is dropping after seeing these glaring bugs in the code ...


Top
 Profile  
 
 Post subject: Re: NullReferenceException from GenericPersistentBag
PostPosted: Thu Jan 28, 2010 2:52 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
You better post that at http://groups.google.com/group/nhusers/topics?hl=en or open an JIRA issue. Noone of the developers is listening here anymore. I recently tested upgrading from 1.2 to 2.1.2GA and didn't ran into that problem, but we don't use lazy loading at all and the tests were at best superficial.

_________________
--Wolfgang


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.