Commit context - missing datasource modified state

Hello guys,

i need your support on a project i am currently working on. I have the following data model, i am representing it based on the datasource of the “root” entity Controller :

image

So basically we are talking about a three level one-to-many relation (Composition). the issue/behavior i am facing is:

  • when adding an “interessentZeitraum” object (the third level) via the given controllers, it is stored correctly in the database
  • when changing a property of or deleting an “interessenZeitraum” object, this action will not be stored in the database.
  • when changing a propetery / deleting an object and at the same time adding at least one new object, all changes will be stored in the database

So in every “preCommit” statement of the three controllers containing “interessentZeitraumDs” as a nested collection datasource, i added a syso-print of the Datasource Context, and noticed the following:

  • When adding an object to interessentZeitraumDs:
    image

  • When changeing or deleting an object of/from interessentZeitraumDs:
    image

So it loses the modified state in the “root” controller “auftragsanfrage”. but as i said, it works fine when adding a new “interessentZeitraumDs” object.

Also, when i print “interessentZeitraumDs.size()” in the “root” controller:

  • when adding an object as mentioned above: it gives me the correct number of objects in the collection
  • when deleting / changeing an object as mentioned above: it always results in zero.

so only when actually adding at least one “interessentZeitraum” object, does the “root” controller, responsible for propagating the changes to the db, contain the objects of the datasource, otherwise the datasource is always empty.

Can someone maybe point me in the right direction? Do i need to check my Datasource setup in the controllers? all other nested collections within that “auftragsanfrage” entity / controller work as they should.

Thanks in advance
Daniel

Hi Daniel,

CUBA 6.x screens cannot work with 3-level (or deeper) compositions, see One-to-Many: Three Levels of Nesting.
Either split your composition as suggested in the guide, or upgrade to CUBA 7.2 and use the new screens API which has no such restrictions.

Regards,
Konstantin

1 Like

Thanks for the Feedback @knstvk. I’ve just imported my Project to Cuba Studio 2019.3. Such a great solution putting the IDE and the Studio together as one.

I will use @gorelov 's guide for CUBA 7 API Migration and give it a go.

Best regards
Daniel