Hi,
I prepared a demo project to address the requirement I was unable to implement.
git@github.com:wrover/composition-with-default-link.git
This is a CUBA Platform sample application showing a quite popular use case of
using compositions in a domain model:
- Entity
Parent
has multipleChild
- One of the children is considered as a “default one” by using a link from
Parent
Of course, it’s possible to use an attribute for
Child
to denote whether it’s
a default child or not, but this approach makes an integrity check for having only
one default child rather difficult.The tricky moment is saving this composition for the first time when creating
because here we have something kind of cyclic references.Now this does not work neither with ASSOCIATE link nor COMPOSITE link.
The error is: SQLIntegrityConstraintViolationException: integrity
constraint violation: NOT NULL check constraint; SYS_CT_10364 table:
APP_PARENT column: DEFAULT_CHILD_ID