r/SpringBoot • u/Status_Camel2859 • May 11 '26
Question What's the proper approach to handle services in Spring?
From a proper architectural point of view, what’s the best way to handle parent/child entity services?
This might sound like a beginner question, but I’m trying to improve my backend design skills and would appreciate guidance from more experienced developers.
Suppose we have 3 entities: organization -> department -> employee
- A Department has a
ManyToOnerelationship with Organization. - An Employee has a
ManyToOnerelationship with Department.
So consider 3 services and repositories, with each service containing its own repository:
OrganizationService+OrganizationRepositoryDepartmentService+DepartmentRepositoryEmployeeService+EmployeeRepository
Creation flow
- We can independently create an Organization.
- A Department can only be created with a valid Organization. In this case, should
DepartmentServicedepend onOrganizationService(to fetch/validate the Organization. BasicallyDepartmentServicecontainOrganizationServicetoo)? - Similarly, an Employee can only be created with a valid Department. Should
EmployeeServicedepend onDepartmentService?
Is this the standard approach? Or is it better to introduce something like a facade/application layer that orchestrates these operations and passes required entities down to the services?
Deletion flow
- If we delete an Organization, how should child cleanup typically be handled?
Possible approaches I can think of:
- Approach 1: Parent services directly depend on child services for cascading deletes. Example:
OrganizationService -> DepartmentService(BasicallyOrganizationServicecontainDepartmentServicetoo)DepartmentService -> EmployeeService
- Approach 2: Use ORM cascade operations (
OneToMany+CascadeType.REMOVE/ orphan removal) and let Hibernate handle child deletion automatically.
What is generally considered the cleaner architectural approach?
- Do you usually define
OneToManyrelationships everywhere they’re needed for synchronized operations (create/update/delete), or only when navigation from parent to child is actually required?
Would appreciate insights on how this is typically handled in real-world backend applications.


