Object Inheritance and JPQL query in studio

I have some classes. Call them SuperClass and SubClass1, SubClass2, and SubClass3. SuperClass is the parent class of the Sub classes. I have another entity with an attribute that associates with the Super class but I want to limit the optionsDatasource for the field to only the instances of SubClass2. I did some searching and learned about the TYPE function (https://doc.cuba-platform.com/manual-6.6/jpql_functions.html) but the manual only seems to give examples of it programmatically, not from the studio. Or perhaps I don’t know how to define parameters from the Datasource editor in the studio. Either way, some direction would be much appreciated.

Answer:

select e from <project>$<superEntity> e
where type(e) = <project>$<subEntity>

Or, regarding the example I gave in the question:

select e from sample$SuperClass e
where type(e) = sample$SubClass2

So now I have a problem. SuperClassLine has a quantity and a SuperClass (similar to the OrderLine example). I tried using the the type function I mentioned above, which works to a point. I can see the subset just fine, but when I try to commit it I discover that the information from the SuperClass can copy just fine, but the information specific to the SubClass2 is not copying because it is not a part of the data in the transaction. I will keep investigating and experimenting, but any advice from your end would be appreciated.

Hi,

Could you provide sample project with the problem?

Thanks,
Subbotin Andrey