Cascade Insert problem

I am having a problem with cascading an insert in a Composite setup.
I have an entity (entity1) which is set with an inheritance strategy of ‘JOINED’. A second entity (entity2) that extends entity1 with discriminator columns and a Composition attribute to a third entity (entity3). My edit screen is based on entity2 and has a datasource for entity2 and a nested CollectionDatasource for entity3. In the edit screen, I add items to the CollectionDatasource in the screen controller by having the CollectionDatasource injected and using the addItem method.
This all works properly when I am editing an existing entity2 item. However, if I am creating a NEW entity2 item which has entity3 items added, it fails to save saying that the id for entity2 is not in the table.
For clarity, I am using platform version 6.3.2

Could you create a sample project for your use case? It will take 20 min of your time and save us from misunderstanding of the problem.

Hi Konstantin,

Please see sample attached, which shows the problem (without additional java coding). This is a standard hsql simple project using 6.3.2. If you just fire up, try to create a NEW entity2 instance that has a new entity3 composite entry, you will get the error.

CascadeInsert.zip (342.9K)

Just FYI - a workaround is to move the composition into entity1 (that entity2 is extending) - this is what I have done in my main project for now - but this might not be suitable in some more complex cases.

Hi Gary,

Thank you for the test project.

The cause of the problem is that EclipseLink ORM doesn’t order inserts properly for this case: it first inserts Entity1, then Entity3, which has a reference to Entity2 that is not inserted yet.

A simple solution is to create the foreign key from Entity3 to Entity1, because identifiers of Entity1 and Entity2 are the same. But Studio will constantly try to change the reference field, which is annoying.

We will try to fix the issue somehow, thanks for the report.

:ticket: See the following issue in our bug tracker:

https://youtrack.cuba-platform.com/issue/PL-8135