Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use org unit stored path [DHIS2-18234] #19626

Open
wants to merge 37 commits into
base: master
Choose a base branch
from

Conversation

larshelge
Copy link
Member

@larshelge larshelge commented Jan 8, 2025

Introduces a new method getStoredPath() on OrganisationUnit.

Note that the path property is mapped with the "property access" mode in Hibernate. Per the Hibernate docs:

Property access mode implies the JPA provider accessing the entity’s state through its getter and setter methods. These methods can be used for encapsulation and additional logic as well.

This means that Hibernate will call getPath() and set the path property as part of all persistence operations. This in turn means that we don't have to recalculate the path value in the DHIS 2 application every time we need the value, as it will be persisted in the database.

The exception is when code modifies the ancestors/parents and relies on an up-to-date path value. Though in those special cases, one can simply call the getPath() method. In all other scenarios, the getStoredPath() method can be called, which should introduce a significant performance gain.

For the getStoredPath() method, if the path is not defined, typically as part of an integration test where the state is not yet flushed to the database, the calculated path based on the org unit ancestors is returned.

Reducing the pressure from re-calculating the path may alleviate the problem of DHIS2-18234 where the UID of the ancestor org units are not reflecting the persisted value.

@larshelge larshelge changed the title WIP: fix: Org unit persisted path WIP: fix: Use org unit stored path [DHIS2-18234] Jan 9, 2025
@larshelge larshelge changed the title WIP: fix: Use org unit stored path [DHIS2-18234] fix: Use org unit stored path [DHIS2-18234] Jan 9, 2025
@larshelge larshelge requested review from netroms and jbee January 9, 2025 16:44
@larshelge larshelge marked this pull request as ready for review January 9, 2025 16:44
@larshelge larshelge requested a review from a team as a code owner January 9, 2025 16:44
Copy link

sonarqubecloud bot commented Jan 9, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant