Polymorphic views

Hi, I have a abstract entity X with subtypes A, B and C

I have another entity Y which has a oneToOne composition of type X

I now want to open an editor screen for Y, I want the view that is used to load Y.X to be based on the concrete type.
The only thing I can specify is a view for type X. I tried creating views with the same name for the subtypes but this doesnt work.

For Clarification, my issue is not related to jpa mapping. my entities work fine, the only problem I have is that the view for loading the entities is always a view on the abstract X type. I want the view to be be based on the actual concrete class.

As a workaround im now using

Datamanager.reload(E, view) as documented in DataManager - CUBA Platform. Developer’s Manual

I am now running against a similar problem with an association.

I have an one-to-many X-A where A is an abstract class that has 2 subclasses B and C,.
The B and C specific properties are not being loaded, how can this be resolved?

Will the same issue arise in version 7 or should this be resolved with the new api?


Unfortunately JPA (and therefore CUBA) is limited in that regard. CUBA Views and JPA loading plans are based on the static entity model and do not take into account real types that are stored in the database.

Only WA helps in this case.

We have a feature request: Generic API for references to entity of any type · Issue #269 · cuba-platform/cuba · GitHub
I think it would help in your case, but feature is not planned for any release.

Hi Andrey,

thanks for the reply, but I’m not sure if I understand.

with jpa loading plans I assume you are referring to entity graphs? I have never actually used this mechanism so I might be off here.

But I checked the specification and javadocs and both the Entitygraph and Subgraph Interfaces have methods to specify subgraphs for loading subclass atrributes.

[EntityGraph (Java(TM) EE 7 Specification APIs)]
[Subgraph (Java(TM) EE 7 Specification APIs)]

also, in your post you state

Only WA helps in this case.
I have no idea what WA is, can you elaborate?
edit: after enumerating all the jpa abbrevations I noticed WA just refers to the “WorkAround” :smiley:

Your work around with DataManager.reload


We use Fetch groups (EclipseLink/UserGuide/JPA/Advanced JPA Development/Performance/Fetch Groups - Eclipsepedia) for loading data.

While loading Y entity system creates fetch group for abstract entity X. In the case of polymorphism the system should create fetch group for X entity with attributes of all subtypes (A, B,C). Because we don’t know what is the child of X type in the database. I’m not sure that the EclipseLink JPA can handle such cases. It requires additional research.


I have currently the same problem. I have a browse screen that should show records of two different entities with the same base class.

Did you manage to solve this problem?

Thanks for your help.

Best regards,

Unfortunately, the issue isn’t solved (Support polymorphic views · Issue #2155 · cuba-platform/cuba · GitHub)

As workaround, place common attributes from the inherited entities to the base entity class.