Queries and Inheritance Joining

Discussions about modeling, execution and management of process/application data.
Forum rules
Make sure every topic contains information about your LSPS version and if relevant also your server OS, client OS, database name and version, and application server name and version.
matt.price
 
Posts: 66
Joined: Thu May 03, 2012 11:51 pm

Queries and Inheritance Joining

Fri Jul 18, 2014 9:26 pm

We have an inheritance model that we use to relate todos with busniess entities that reside in our business database. We call these records EntityTodo which relate Todo to our Entity record. Our MainBusniess record then inherits from this Enity record.

I want to query all EntityTodo records and use criteria from the MainBusiness type, but I'm unable to since I can't join on the MainBusiness class via the path exression.

I assume this is due to scope, where the EntityTodo has no knowlegde of the MainBusiness class that is inheriting from it. Is there a way to join in this scenario or should we inherit the EntityTodo as MainBusinessEntityTodo (single table, backfilling the discriminator)? Using MainBusinessEntityTodo in place of EntityTodo...

Ondrej Danko
 
Posts: 31
Joined: Mon Feb 27, 2012 1:14 pm

Re: Queries and Inheritance Joining

Mon Jul 21, 2014 12:59 pm

Hi,

Thanks for the post. The reason why we don't support aforementioned query (getAllEntityTodo where entityTodo.entity.SUB_CLASS_TYPE='MainBusinessEntity' and entityTodo.entity.value='someValue') is that we currently (LSPS 2.7) don't have construct for SUB_CLASS_TYPE (discriminator). We will investigate technical possibilities and let you know if this is possible to address also for 2.7.

Meanwhile, see screenshots below, would that be a workaround for you?
datatypes.png
Datatype model.
datatypes.png (8.69 KiB) Viewed 3866 times

query.png
Query.
query.png (18.98 KiB) Viewed 3866 times


Generated sql:
Code: Select all
select
   distinct
   entity_tod0_."ID" as ID1_1_,
   entity_tod0_."ENTITY_ID" as ENTITY_I2_1_
from "ENTITY_TODO" entity_tod0_
left outer join "ENTITY" entity2_ on entity_tod0_."ENTITY_ID"=entity2_."ID"
cross join "MAIN_BUSINESS_ENTITY" main_busin1_
inner join "ENTITY" main_busin1_1_ on main_busin1_."ID"=main_busin1_1_."ID"
where
   entity2_."ID"=main_busin1_."ID" and
   main_busin1_."VALUE"=?


Thanks.

matt.price
 
Posts: 66
Joined: Thu May 03, 2012 11:51 pm

Re: Queries and Inheritance Joining

Mon Aug 04, 2014 8:57 pm

Thanks for the feedback.

Unfortunately, I had to branch this work and hopefully will pick it back up soon.

Return to Data modeling

Who is online

Users browsing this forum: No registered users and 1 guest