Inheritance hierarchy code

Posts   
 
    
paulshealy
User
Posts: 22
Joined: 13-Jun-2005
# Posted on: 27-Jul-2006 23:01:01   

I've recently added an inheritance hierarchy to our code and the generated code won't compile (using SelfServicing, v2.0).

The relevant hierarchy bit looks like this:

Department -- subtypes: IVDepartment, ... | Position -- subtypes: IVPosition, ...

This is a target-per-entity-hierarchy setup. Department and Position are abstract. The relationship in the DB is Position(Parent) -> Department(ID). Parent and ID are in the base classes.

In the generated code, the DepartmentDAO has code like this:



public bool GetMultiUsingPositionCollectionViaIVPosition(<snip>)
        {
            <snip>
            relations.Add(DepartmentEntity.Relations.IVPositionEntityUsingParent, "IVPosition_");
            <snip>
        }


but there is no such relation on DepartmentEntity; the only Department - Position relation is PositionEntityUsingParent.

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 28-Jul-2006 07:56:21   

So I assume you get a compilation error over "IVPositionEntityUsingParent". Being undefind.. correct?

Using the LLBLGen Pro Designer: would you please validate the relations subTab of the DepartementEntity, PositionEntity & IVPositionEntity?

paulshealy
User
Posts: 22
Joined: 13-Jun-2005
# Posted on: 28-Jul-2006 15:02:21   

Walaa wrote:

So I assume you get a compilation error over "IVPositionEntityUsingParent". Being undefind.. correct?

Correct.

Walaa wrote:

Using the LLBLGen Pro Designer: would you please validate the relations subTab of the DepartementEntity, PositionEntity & IVPositionEntity?

On Department, the Position relation (Department - Position (1:n)) appears. Also, I have Department - Position (m:n) (via IVPosition), which has two subrelations: Department - IVPosition (1:n) on Department.ID = IVPosition.Parent, and IVPosition - Position (m:1) on IVPosition.NonHotelColumn = Position.ID. This is odd, because NonHotelColumn is a self-reference that is found in another sub-type of position (GPPosition).

On Position, the Position - Department (m:1) relation, on Parent = ID, appears. Other department relations appear, but all go through a third table. On IVPosition, the only relations are those from the Position (they're all grayed out).

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 28-Jul-2006 15:20:21   

but there is no such relation on DepartmentEntity; the only Department - Position relation is PositionEntityUsingParent.

I have Department - Position (m:n) (via IVPosition), which has two subrelations: Department - IVPosition (1:n) on Department.ID = IVPosition.Parent, and IVPosition - Position (m:1) on IVPosition.NonHotelColumn = Position.ID. This is odd, because NonHotelColumn is a self-reference that is found in another sub-type of position (GPPosition).

The above 2 quotes are contradicting.

It seems that's the generated code does not match what the designer shows. So would you please re-generate the code and make sure you re-build it again. I encourage you to re-generate the code in a new folder just for the sake of testing. There might be some files under source control that are not overwritten.

paulshealy
User
Posts: 22
Joined: 13-Jun-2005
# Posted on: 31-Jul-2006 15:05:54   

Walaa wrote:

but there is no such relation on DepartmentEntity; the only Department - Position relation is PositionEntityUsingParent.

I have Department - Position (m:n) (via IVPosition), which has two subrelations: Department - IVPosition (1:n) on Department.ID = IVPosition.Parent, and IVPosition - Position (m:1) on IVPosition.NonHotelColumn = Position.ID. This is odd, because NonHotelColumn is a self-reference that is found in another sub-type of position (GPPosition).

The above 2 quotes are contradicting.

It seems that's the generated code does not match what the designer shows. So would you please re-generate the code and make sure you re-build it again. I encourage you to re-generate the code in a new folder just for the sake of testing. There might be some files under source control that are not overwritten.

I checked on it this morning. A newly generated copy has the same problem. Looking at DepartmentDAO some more, methods like GetMultiUsingPositionCollectionViaIVPositon exist for each of the subtypes of Position. All of them use the NonHotelColumn self-relation on Position and the corresponding Department - Position relation. Position is abstract, and it looks like perhaps the Department - concrete Position relations aren't being generated.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39590
Joined: 17-Aug-2003
# Posted on: 01-Aug-2006 10:58:52   

Please mail your .lgp file to support AT llblgen.com and I'll have a look. I can't determine from this thread what exactly is wrong without having the project in front of me.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39590
Joined: 17-Aug-2003
# Posted on: 01-Aug-2006 14:41:27   

Bug in the routine which determines the relations. As you have a relation with self on the supertype (position), this relation opens the road to m:n relations via a subtype as the intermediate entity, in this case the types GPPosition, IVPosition and PPPosition.

The m:1 / 1:n relation finder correctly weeds out these supertype/subtype relations if both pk and fk side are defined on the supertype, as these should be ignored, the m:n relation finder does not.

This leads to incorrectly m:n relations which in code are generated as a fetch using two 1:n relations, though these dont exist, which leads to incompilable code.

I'll fix this. As a workaround, hide the m:n relations in Department for now (also on the other side of course).

Frans Bouma | Lead developer LLBLGen Pro