Table inheritance and relationship issue

Posts   
 
    
Rosacek
User
Posts: 155
Joined: 18-Mar-2012
# Posted on: 17-Oct-2015 23:41:04   

LLBL 4.2, Pro runtime Framework

Hi, I found following problem.

I have table PARTY and inherited table PERSON

Then I have table PARTYROLE and inherited table WORKER

PARTY to PARTYROLE is 1:N

In LLBL designer I cannot see relationship from PersonEntity to WorkerEntity I can see just relationship to PartyRoleEntity.

The background When I want to load all Persons that are Workers, I would do in MSSQL someting like: Select * From Person JOIN Party ...JOIN PartyRole ...JOIN Worker...

In code I would do:

filter.Relations.Add(EntityClasses.PersonEntity.Relations.WorkerEntityUsingPartyId)
adapter.FetchEntityCollection(ecPersons, filter)

but this way is not possible

I can do just:

filter.Relations.Add(EntityClasses.PersonEntity.Relations.PartyRoleEntityUsingPartyId)

but I cannot continue by

filter.Relations.Add(EntityClasses.PartyRoleEntity.Relations.WorkerEntityUsingPartyRoleId)

See DB BAK and LLBL project attached

Attachments
Filename File size Added on Approval
sample.zip 124,003 17-Oct-2015 23:41.24 Approved
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 19-Oct-2015 07:21:59   

You can just add the relations that don't belong to inheritance and then add a subtype filter. See this documentation link for more info.

David Elizondo | LLBLGen Support Team
Rosacek
User
Posts: 155
Joined: 18-Mar-2012
# Posted on: 19-Oct-2015 14:10:27   

Just to make it clear, Worker is not subtype of Person. It is role of Person

If i use just do

Dim filter As New RelationPredicateBucket()
filter.PredicateExpression.Add(EntityClasses.WorkerEntity.GetEntityTypeFilter())adapter.FetchEntityCollection(ecPersons, filter)

then the JOIN is: Person To Party WHERE Worker.WorkerID IS NOT NULL this is incomplete as missing join to PartyRole and then PartyRole To Worker

I tried this:

Dim filter As New RelationPredicateBucket()
filter.Relations.Add(EntityClasses.WorkerEntity.Relations.PartyEntityUsingPartyId)
adapter.FetchEntityCollection(ecPersons, filter)

and looks it works fine. I get all Person having Worker role JOIN IS Worker To PartyRole and PartyPole To Party and Party To Person

I hope this is correct attitude.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 19-Oct-2015 19:16:45   

Dim filter As New RelationPredicateBucket() filter.Relations.Add(EntityClasses.WorkerEntity.Relations.PartyEntityUsingPartyId) adapter.FetchEntityCollection(ecPersons, filter)

and looks it works fine. I get all Person having Worker role JOIN IS Worker To PartyRole and PartyPole To Party and Party To Person

I hope this is correct attitude.

It is correct as you are fetching Persons.