chore: Extract FileResource assignment update [DHIS2-21378]#23879
Merged
Conversation
enricocolasante
force-pushed
the
DHIS2-21378-file-resource
branch
from
May 12, 2026 09:43
cf6e2a6 to
68da439
Compare
enricocolasante
force-pushed
the
DHIS2-21378-file-resource
branch
from
May 12, 2026 12:52
68da439 to
6e51039
Compare
enricocolasante
marked this pull request as ready for review
May 15, 2026 07:22
teleivo
approved these changes
May 15, 2026
| List<TrackedEntityAttributeValue> attributeValues = | ||
| trackedEntityAttributeValueService.getTrackedEntityAttributeValues(trackedEntity); | ||
| assertEquals(5, attributeValues.size()); | ||
| manager.clear(); |
Contributor
There was a problem hiding this comment.
and if you clear before flush I think there is nothing to flush
muilpp
approved these changes
May 18, 2026
enricocolasante
enabled auto-merge (squash)
May 21, 2026 12:54
|
enricocolasante
added a commit
that referenced
this pull request
Jul 7, 2026
… (2.43) (#24286) * feat: remove EntityManager from TrackerPersister [DHIS2-21378] (#23797) * feat: remove EntityManager from TrackerPersister interface and method parameters [DHIS2-21378] * Use default timezone (cherry picked from commit 052d3ac) * feat: decouple ChangeLogAccumulator from Hibernate Session [DHIS2-21378] (#23836) (cherry picked from commit 0c1779f) * chore: Extract FileResource assignment update [DHIS2-21378] (#23879) * chore: Extract FileResource assignment update [DHIS2-21378] * Code review fixes * Code review fixes (cherry picked from commit 83542f4) * feat: stage TEAV writes through EntityWriteBatch [DHIS2-21378] (#23970) (cherry picked from commit b30c1ce) * feat: Batch entity when persisting [DHIS2-21378] (#24005) (cherry picked from commit 100dff1) * feat: remove EntityManager from DefaultTrackerBundleService [DHIS2-21378] (#24024) (cherry picked from commit 3759453) * feat: TrackedEntity JDBC insert [DHIS2-21378] (#24027) (cherry picked from commit 4eaf6ba) * feat: TrackedEntity JDBC update [DHIS2-21378] (#24079) (cherry picked from commit d4af287) * feat: Enrollment JDBC insert/update [DHIS2-21378] (#24081) * feat: TrackedEntity JDBC update [DHIS2-21378] * feat: Enrollment JDBC insert/update [DHIS2-21378] * Remove L2 caching from enrollment * Code review fixes * Code review fixes (cherry picked from commit 34d629e) * feat: Tracker event JDBC insert/update [DHIS2-21378] (#24082) * feat: TrackedEntity JDBC insert [DHIS2-21378] * feat: TrackedEntity JDBC update [DHIS2-21378] * feat: Enrollment JDBC insert/update [DHIS2-21378] * feat: Tracker event JDBC insert/update [DHIS2-21378] (cherry picked from commit 435872b) * feat: Single event JDBC insert/update [DHIS2-21378] (#24083) * feat: TrackedEntity JDBC insert [DHIS2-21378] * feat: TrackedEntity JDBC update [DHIS2-21378] * feat: Enrollment JDBC insert/update [DHIS2-21378] * feat: Tracker event JDBC insert/update [DHIS2-21378] * feat: Single event JDBC insert/update [DHIS2-21378] * Format code (cherry picked from commit 9703e4f) * feat: Relationship JDBC insert/update [DHIS2-21378] (#24093) * feat: TrackedEntity JDBC insert [DHIS2-21378] * feat: TrackedEntity JDBC update [DHIS2-21378] * feat: Enrollment JDBC insert/update [DHIS2-21378] * feat: Tracker event JDBC insert/update [DHIS2-21378] * feat: Single event JDBC insert/update [DHIS2-21378] * feat: Relationship JDBC insert/update [DHIS2-21378] (cherry picked from commit 658f0a8) * feat: TEAV JDBC insert/update [DHIS2-21378] (#24098) * feat: TrackedEntity JDBC update [DHIS2-21378] * feat: Enrollment JDBC insert/update [DHIS2-21378] * feat: Tracker event JDBC insert/update [DHIS2-21378] * feat: Single event JDBC insert/update [DHIS2-21378] * feat: Relationship JDBC insert/update [DHIS2-21378] * feat: TEAV JDBC insert/update [DHIS2-21378] * Code review fixes * Fix tests * Fix idScheme issue for TEAV (cherry picked from commit 4e3367c) * fix: Refactor persistence layer in tracker importer [DHIS2-21378] (#24197) * feat: TrackedEntity JDBC update [DHIS2-21378] * feat: Enrollment JDBC insert/update [DHIS2-21378] * feat: Tracker event JDBC insert/update [DHIS2-21378] * feat: Single event JDBC insert/update [DHIS2-21378] * feat: Relationship JDBC insert/update [DHIS2-21378] * feat: TEAV JDBC insert/update [DHIS2-21378] * Code review fixes * Fix tests * Fix idScheme issue for TEAV * fix: Refactor persistence layer in tracker importer [DHIS2-21378] * Fix merge (cherry picked from commit 194dcd1) * fix: Harmonize db sequences for tracker [DHIS2-21378] (#24208) * fix: Harmonize db sequences for tracker [DHIS2-21378] * Fix relationshipitemid (cherry picked from commit f52eefa) * fix: Rename conflicting migration [DHIS2-21378] (#24218) (cherry picked from commit 7aefc1c) No-op on 2.43: this PR renamed V2_44_12 -> V2_44_13 to avoid a master-only Flyway version clash. On 2.43 the migration is numbered V2_43_63 (its own series), so no rename is needed. Empty commit kept to preserve the full DHIS2-21378 backport history. * refactor: Split EntityWriteBatch into per-entity writers [DHIS2-21378] (#24227) * refactor: Split EntityWriteBatch into per-entity writers [DHIS2-21378] * chore: Migrate ownership from Hibernate to JDBC [DHIS2-21378] * Code review fixes (cherry picked from commit 331503a) * chore: Migrate ownership from Hibernate to JDBC [DHIS2-21378] (#24239) * refactor: Split EntityWriteBatch into per-entity writers [DHIS2-21378] * chore: Migrate ownership from Hibernate to JDBC [DHIS2-21378] (cherry picked from commit 7ba2431) * perf: Batch existing-TEAV lookup in tracker import [DHIS2-21378] (#24244) * refactor: Split EntityWriteBatch into per-entity writers [DHIS2-21378] * chore: Migrate ownership from Hibernate to JDBC [DHIS2-21378] * Code review fixes * perf: Batch existing-TEAV lookup in tracker import [DHIS2-21378 * Code review fixes * Code review fixes (cherry picked from commit 2972a82) * perf: Constant-text unnest INSERTs in tracker import [DHIS2-21378] (#24250) * refactor: Split EntityWriteBatch into per-entity writers [DHIS2-21378] * chore: Migrate ownership from Hibernate to JDBC [DHIS2-21378] * Code review fixes * perf: Batch existing-TEAV lookup in tracker import [DHIS2-21378 * perf: Constant-text unnest INSERTs in tracker import [DHIS2-21378] * perf: Cache UserInfoSnapshot JSON per batch in tracker import [DHIS2-21378] * Revert "perf: Cache UserInfoSnapshot JSON per batch in tracker import [DHIS2-21378]" This reverts commit 7084379. * Add tests to cover fields import (cherry picked from commit 7305f9f) * perf: Cache UserInfoSnapshot JSON per batch in tracker import [DHIS2-21378] (#24252) * refactor: Split EntityWriteBatch into per-entity writers [DHIS2-21378] * chore: Migrate ownership from Hibernate to JDBC [DHIS2-21378] * Code review fixes * perf: Batch existing-TEAV lookup in tracker import [DHIS2-21378 * perf: Constant-text unnest INSERTs in tracker import [DHIS2-21378] * perf: Cache UserInfoSnapshot JSON per batch in tracker import [DHIS2-21378] * Fix duration based Tracker perf tests * Fix formatting (cherry picked from commit a03204c) * fix: Preserve storedby on tracker JDBC writers for 2.43 [DHIS2-21378] Backport adaptation. On master, DHIS2-21537 removed storedBy from the TrackedEntity/Enrollment/Event write path (and renamed TEAV storedBy to updatedBy). 2.43 deliberately keeps storedBy, so the JDBC writers backported from master must persist the storedby column that 2.43's tables still have. TrackerObjectsMapper still sets storedBy on the new-entity branch for TE, enrollment and events, so storedby is insert-only here (mirrors createdby): added the storedby column + bind to the INSERT of TrackedEntityWriter, EnrollmentWriter, SingleEventWriter and TrackerEventWriter. TeavWriter was already adapted (storedby column + getStoredBy) when the earlier commits were cherry-picked. Keeps the 2.43-only shouldSetStoredByToAuthenticatedUser* tests green. * Fix note persister * Fix formatting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Extracts the FileResource assignment update during tracker import out of the Hibernate persistence context and into a direct JDBC
UPDATE. This avoids dirty-marking the entity and preventsPostUpdateAuditListener(and other Hibernate audit listeners) from firing for every file-resource assignment during a tracker import.FileResourceStore.updateAssignment(uid, assigned, fileResourceOwner)backed byJdbcTemplate, settingisassigned,fileresourceowner, andlastupdated = now()in a single statement.entityManager.merge(fileResource)inAbstractTrackerPersister#assignFileResourcewith the new store method. The in-memory copy in the preheat is intentionally left as-is — nothing reads it back later in the import.FileResourceStorethrough all concrete persisters:EnrollmentPersister,RelationshipPersister,SingleEventPersister,TrackedEntityPersister,TrackerEventPersister.Performance
25726592602
25726590062
25726586827
25726584415
compare mode: 4 baseline run(s), 4 candidate run(s) on load profile
Median Response Time (p50) (ms)
95th Percentile Response Time (p95) (ms)
⬇️ = faster, ⬆️ = slower
Next steps
formatDate:SimpleDateFormat→static final DateTimeFormatter─EntityManagerfromTrackerPersisterinterface and all method parameters - feat: decouple ChangeLogAccumulator from Hibernate Session [DHIS2-21378] #23836ChangeLogAccumulatorfrom HibernateSession; obtain thetransaction-bound
ConnectionviaDataSourceUtilsinstead ofsession.doWork()FileResourceassignment update out ofAbstractTrackerPersisterinto
FileResourceStoreEntityWriteBatch; accumulate and batch-flush TEAV writes(multi-row INSERT / unnest UPDATE / tuple DELETE)
inserts and updates in
EntityWriteBatch; remove allentityManager.flush()callsupdateTrackedEntitiesLastUpdatednamed query withNamedParameterJdbcTemplate; remove last Hibernate dependency fromDefaultTrackerBundleService(
TrackedEntity→Enrollment→TrackerEvent/SingleEvent→Relationship)