Have you a complete test case ? On Tue, Jun 1, 2010 at 7:17 PM, Jim Geurts <[email protected]> wrote:
> I looked into this a bit more. Unfortunately, my knowledge of > NHibernate is not on par with everyone else on this list, so I don't > know how much help I can be. > > I tracked down some code that is currently commented out, but it looks > like an area that has presented problems in the past (based on the > code comments). It is in the PersistentBag.cs file, line 73. The > check for null is commented out because of NH-750. Because that check > is commented out, I get unexpected null objects in my collection. > > Anyone have any insight into this and how best to go about fixing the > behavior? > > > > > On May 11, 5:36 pm, Jim Geurts <[email protected]> wrote: > > Hi all, > > > > I apologize for cross posting this message to the dev list, but I > > haven't gotten a response on the users list yet. Hopefully someone > > here can shed some light on the behavior I'm seeing. > > > > I have a bag defined for a many-to-many list: > > > > <class name="Author" table="Authors"> > > <id name="Id" column="AuthorId"> > > <generator class="identity" /> > > </id> > > <property name="Name" /> > > <bag name="Books" table="Author_Book_Map" where="IsDeleted=0" > > fetch="join"> > > <key column="AuthorId" /> > > <many-to-many class="Book" column="BookId" > > where="IsDeleted=0" /> > > </bag> > > </class> > > > > If I return all author objects (using something like > > Session.Query<Author>().List<Author>()), I will get what initially > > appeared to be duplicate Author records: > > > > The extra author objects are created when an author is mapped to Book > > objects that have IsDeleted = 1 and IsDeleted = 0. Rather than > > creating one Author object with an enumerable that contains only the > > books with IsDeleted = 0, it will create two author objects. The > > first author object has a Books enumerable that contains books with > > IsDeleted = 0. The second author object will contain an enumerable of > > null book > > objects. > > > > I'm thinking part of the problem stems from the map table objects > > linking to rows that satisfy the where condition on the bag object but > > do not meet the many-to-many where condition. > > > > This is using NH 3.0.0.1001. Is this a configuration issue or > > something else? > > > > Thanks, > > > > Jim > -- Fabio Maulo
