Null reference in DaoBase.DetermineDifferentValuesForParameterizedPPath()

Posts   
 
    
PatrickD
User
Posts: 65
Joined: 05-Sep-2006
# Posted on: 29-Oct-2007 15:51:18   

I have updated to the build of September 24th and since that update I get the following exception on code that has not been changed:


System.NullReferenceException: Object reference not set to an instance of an object.

at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.DetermineDifferentValuesForParameterizedPPath(IEntityCollection rootEntities, IPrefetchPath prefetchPath, IPrefetchPathElement currentElement, Int32& amountRootEntitiesUsable) 
at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.FetchPrefetchPath(IEntityCollection rootEntities, IPredicate filter, IRelationCollection relations, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IPrefetchPath prefetchPath, ITransaction containingTransaction, Boolean forceParameterizedPPath) 
at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.PerformGetMultiAction(ITransaction containingTransaction, IEntityCollection collectionToFill, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IPredicate selectFilter, IRelationCollection relations, IPrefetchPath prefetchPathToUse, ExcludeIncludeFieldsList excludedIncludedFields, Int32 pageNumber, Int32 pageSize) 
at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.GetMulti(ITransaction containingTransaction, IEntityCollection collectionToFill, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IEntityFactory entityFactoryToUse, IPredicate selectFilter, IRelationCollection relations, IPrefetchPath prefetchPathToUse, ExcludeIncludeFieldsList excludedIncludedFields, Int32 pageNumber, Int32 pageSize) 
at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase`1.GetMulti(IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relations, IPrefetchPath prefetchPathToUse, ExcludeIncludeFieldsList excludedIncludedFields, Int32 pageNumber, Int32 pageSize) 
at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase`1.GetMulti(IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relations, IPrefetchPath prefetchPathToUse, Int32 pageNumber, Int32 pageSize) 
at IPParking.ParkBase.BusinessLayer.Identification.ReadOutstanding(Int32 maximumRows, Int32 startRowIndex, String sort) in Identification.cs:line 430 
at IPParking.ParkBase.TestSuite.IdentificationFixture.ReadAllOutstanding() in IdentificationFixture.cs:line 32 

Class Identification is a supertype. The code called is:


IdentificationCollection identificationCollection = new IdentificationCollection();
identificationCollection.GetMulti(filterExpression, 0, sortExpression, readRelations, prefetchPath, 0, 0);

Variables filterExpression, sortExpression, readRelations and prefetchPath are not null and valid, as the unit test of which this is code functioned correctly until the update.

Regards,

Patrick

goose avatar
goose
User
Posts: 392
Joined: 06-Aug-2007
# Posted on: 29-Oct-2007 22:05:15   

Hi PatrickD, could you please provide more information in order to reproduce the error?

PatrickD
User
Posts: 65
Joined: 05-Sep-2006
# Posted on: 29-Oct-2007 22:18:37   

goose wrote:

Hi PatrickD, could you please provide more information in order to reproduce the error?

I would like to, but could you give me a hint of what kind of information to provide, cuz I really got no idea. I hoped the stack trace would give you a clue in which direction to look.

Regards,

Patrick

goose avatar
goose
User
Posts: 392
Joined: 06-Aug-2007
# Posted on: 29-Oct-2007 22:37:25   

For instance could you provide the complete code snippet that causes the exception?

PatrickD
User
Posts: 65
Joined: 05-Sep-2006
# Posted on: 30-Oct-2007 09:21:24   

goose wrote:

For instance could you provide the complete code snippet that causes the exception?

The code is quite complex, so that is not possible.

However, I have narrowed down the error:

I have four entities: SuperTypeA, SubTypeB, SubTypeC and EntityD. SubTypeB and SubTypeC are subclasses of SuperTypeA. EntityD is related to SubTypeB.

The code that fails is the following:


SuperTypeACollection collection = new SuperTypeACollection();
collection.GetMulti(filterExpression, 0, sortExpression, relations, prefetchPath,0,0);

I use the following prefetch path:


IPrefetchPath prefetchPath = new PrefetchPath((int)EntityType.SubTypeBEntity);
prefetchPath.Add(SubTypeBEntity.PrefetchPathEntityD);

Now when I create relations like in the following code snippet, the method succeeds.


relations = new RelationCollection();
relations.Add(SubTypeBEntity.Relations.EntityDEntityUsingFK, JoinHint.Left);

However, when I specify null or an empty RelationCollection, the mentioned exception occurs.

In the previous release of LLBLGen Pro 2.5 this was legal.

Regards,

Patrick

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 30-Oct-2007 11:00:16   

Please try the following code instead:

SuperTypeACollection collection = new SuperTypeACollection();

IPrefetchPath prefetchPath = new PrefetchPath((int)EntityType.SuperTypeEntity); prefetchPath.Add(SubTypeBEntity.PrefetchPathEntityD);

collection.GetMulti(filterExpression, 0, sortExpression, relations, prefetchPath,0,0);

PatrickD
User
Posts: 65
Joined: 05-Sep-2006
# Posted on: 30-Oct-2007 11:16:39   

Yes, that works.

As the original code worked in the previous release, will that also be possible again in future versions or is this the new way to go. In other words: is it a bug or by design?

Anyway, thanks for the solution.

Patrick

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 30-Oct-2007 11:23:10   

It's by design as explained in the docs under Polymorphic Prefetch Paths. "Using the generated code -> Adapter/SelfServicing -> Prefetch paths"

PatrickD
User
Posts: 65
Joined: 05-Sep-2006
# Posted on: 30-Oct-2007 11:27:51   

Ok, thanks again.