How to work with relationships between tables(Deep Composition)

Good day

-I have three tables: Projects, Task and Sub-Task.
-Relationship between tables: One Project can have many Task, One Task can have many SubTasks.
Attribute Type: Composition

-User of the system are assigned according to their roles(Project Supervisor, Task Performer and Sub-Task Performer). Project Supervisor can edit all the projects he created, that includes all the Task and Sub-Tasks as well. Task Performer and Sub-Task Performer can edit only the Status of Tasks and Sub-Tasks they are assigned to.
Status can be: Planned, In_Progress, On_Hold and Complete.

*A Project Status is set to complete when all its Tasks status are set to complete.
*A Task status is set to complete when all its Sub-Tasks status are set to complete.

*I implemented this rule by using entity Listeners(BeforeInsertEntityListener and BeforeUpdateEntityListener).


  1. When I log in as a Task Performer or Sub-Task Performer and change all their Statuses to complete from the Task and Sub-Task tables, It does not trigger the BeforeUpdateEntityListener of Project to set the Projects Status to complete.

  2. Give me good simpler examples or references about Transaction Listeners with an explanation where to apply it and how different they are from Entity Listeners.

Am I doing it wrong? Please help

Thank you in advance

1 Like


In your Task entity listener, you should get related Project and its collection of tasks, check if all of them are completed and if so, set appropriate status to the project. It will be saved together with the updated Task.

The same is for SubTasks.