More Subclass relationship issues...

Posts   
 
    
stef
User
Posts: 28
Joined: 14-Jun-2005
# Posted on: 01-Dec-2005 05:38:49   

Hi Frans, Following on from... http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=4750

I'm now writing some code to use the relationships defined between subclasses. From the sample in the thread above:

  • create a new EventTypeEntity
  • create a new EventEntity, setting the EventType property to the newly created EventTypeEntity
  • save the object graph

Sample Code:

EventTypeEntity eventType = GeneralEntityFactory.Create(EntityType.EventTypeEntity) as EventTypeEntity; eventType.Uno=2; eventType.Name = "TestType2"; eventType.Description = "Test description";

EventEntity evnt = GeneralEntityFactory.Create(EntityType.EventEntity) as EventEntity; evnt.Uno=3; evnt.Name = "Test2"; evnt.EventType = eventType; //FAILS

using(DataAccessAdapter adapter = new DataAccessAdapter()) { adapter.SaveEntity(evnt, true); }

[The Uno property is the UniqueID/PK for any entity]

The assignment of eventType to event.EventType fails in the generated code: EventEntity.SetupSyncEventType(IEntity2 relatedEntity) on line base.SetEntitySyncInformation("EventType", _eventType, EventEntity.Relations.EventTypeEntityUsingCampaignTypeUno);

The call into the base class fails, throwing the following exception: System.NullReferenceException : Object reference not set to an instance of an object.

If I replace the EventTypeEntity and EventEntity with the superclasses (CampaignTypeEntity and CampaignEntity - setting property CampaignType) the code works - the object graph is correctly committed.

Could there be more gremlins in the relationships for subclasses? Stef

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 01-Dec-2005 07:04:48   

Would you please describe your entities hierarchy and their relations.

Thanks

stef
User
Posts: 28
Joined: 14-Jun-2005
# Posted on: 01-Dec-2005 09:47:54   

Walaa wrote:

Would you please describe your entities hierarchy and their relations.

Thanks

Please see the forum article given in the original post, this gives a detailed description of the database schema and the LLBLGen entities.

In addtion to the Event to EventType relationship described in the referenced thread, I added a Campaign to CampaignType relationship to see if the behaviour was the same for the superclass. If the super classes (and the relationship between them) are used the code works as expected - two new records are saved to the database and the foreign key column is populated. If the subclasses are used then an error occurs as discussed.

Stef

BTW, I'm using the 28th Nov release of LLBLGen.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 01-Dec-2005 11:19:15   

With your testcode I've reproduced it. I'll look into it.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 01-Dec-2005 11:42:45   

Otis wrote:

With your testcode I've reproduced it. I'll look into it.

(edit) It's a bug in the fieldfactory somewhere. If the entity has no fields, the entityfieldfactory method for that entity doesn't have a switch statement, so it also doesn't produce field objects which it inherits from a parent (which is the cause of this issue).

(edit): If HasFields requires a parameter which checks if it has fields including the inherited fields. That's currently not there. I can now add that parameter but then some people will update the templates and not the task performer, I can also remove the if statement and always emit a default. I'll go for the second option.

(edit): that indeed fixes it. I hope to have a fix later today. If you desperately need the template NOW, please let me know.

Frans Bouma | Lead developer LLBLGen Pro
stef
User
Posts: 28
Joined: 14-Jun-2005
# Posted on: 01-Dec-2005 19:07:34   

Thanks Frans, I'm happy to hold off for the update. The support you provide is second to none, the sub 24 hour turn around on issues such as this is superb and all too rare elsewhere.

Thanks, Stef

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 01-Dec-2005 22:57:51   

Ok, I'm waiting for a report on a temp fix and if that succeeds a new build is released tomorrow (friday). I hope the problems about the subtype-subtype relations are then finally all gone simple_smile

Frans Bouma | Lead developer LLBLGen Pro