[BUG] [CUBA 7] [7.1.4] Nested entity is not fetched properly with the assigned view

Reproducing project:
nestedviews.zip (88.7 KB)

Long story short, I have 3 entities:

  • Event
  • BaseEntity
  • InheritedEntity

BaseEntity has a @OneToMany, @Composition relation with the Event.
InheritedEntity inherits BaseEntity.
BaseEntity has @OneToMany relationship with InheritedEntity, thus InheritedEntity has a @OneToOne relationship with BaseEntity.

Now that there’s a bit of context, my issue is that, having a InheritedEntity, that contains a BaseEntity, that has an Event, in the InheritedEntity browser, the Event list present on the BaseEntity, that is attached to the InheritedEntity is fetched as having 0 elements. This behavior is incorrect.

If I reload the the BaseEntity with DataManager as follows: dataManager.reload(inheritedEntity.getBaseEntity, "baseEntity-view"), the list is fetched as having the correct number of Event entities in it.

The CollectionContainer<InheritedEntity> view is set to a view that loads the InheritedEntity's BaseEntity with the same view as above, specifically baseEntity-view.

My explanations are meant to understand easily the attached project in which this issue is visible.
How to check if this issue is visible?

  • Open InheritedEntity browse
  • Observe that in the InheritedEntity.event (generated) column there is no value.
  • Go to Entity Inspector and find the BaseEntity contained in the problematic InheritedEntity (the single one from the browser).
  • Open it for editing and observe that there is an Event entity attached to it.

Thank you,
Alex

2 Likes

Thank you for reporting the problem. We have created an issue: Nested entity isn't fetched properly by view · Issue #2691 · cuba-platform/cuba · GitHub

I have found a workaround for the problem: setting fetch mode UNDEFINED for events property, e.g.:

<view entity="nestedviews_BaseEntity" name="baseEntity-view" extends="_local">
        <property name="events" view="_minimal" fetch="UNDEFINED"/>
</view>
1 Like

Thanks for the workaround, Andrey :+1: