feat: Single event JDBC insert/update [DHIS2-21378]#24083
Draft
enricocolasante wants to merge 8 commits into
Draft
feat: Single event JDBC insert/update [DHIS2-21378]#24083enricocolasante wants to merge 8 commits into
enricocolasante wants to merge 8 commits into
Conversation
8ee78f7 to
fdc5b6b
Compare
fdc5b6b to
b8b8610
Compare
|
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.



feat: Single event JDBC insert/update DHIS2-21378
Summary
Continues the Hibernate→JDBC tracker import migration (Phase 6) by moving SingleEvent writes off
EntityManagerand onto raw JDBC, following the same pattern already established forTrackedEntity,EnrollmentandTrackerEvent. SingleEvent mirrors theTrackerEventshape, writing to the dedicatedsingleeventtable (split out perV2_43_21__split_event_table.sql)— without
enrollmentid(single events aren't tied to an enrollment) and withoutscheduleddate. This includes cascade-handling for event notes (previously managed by Hibernate via@OneToMany(cascade=ALL)) and JSON serialization of theeventdatavaluesjsonb column. LikeTrackerEvent,SingleEventis not L2-cached, so no cache removal was required.Changes
EntityWriteBatch— the bulk of the work:INSERTintosingleevent. Ids are pre-allocated fromsingleevent_sequencebyAbstractTrackerPersister.unnestUPDATEagainstsingleevent, writing only the columns mutated byTrackerObjectsMapper.mapSingleEventon the updatebranch. Insert-only columns (
uid,created,createdbyuserinfo,deleted) and externally-owned columns (lastsynchronized) are deliberately excluded.eventdatavaluesis serialized as a JSON object keyed bydataElementuid, matchingJsonEventDataValueSetBinaryType, so the on-disk shape is byte-identical to the Hibernate-writtenvalue.
INSERTs (noteand thesingleevent_notesjoin table), replacing Hibernate's cascade behaviour. New note ids areallocated from
note_sequence;sort_orderis derived from the 1-based list position. Notes are append-only on update — only notes withid == 0are treated as new. The note-row insertlogic is shared with the enrollment / tracker-event paths via the
NoteToInsertabstraction.UPDATEbypasses Hibernate, the preheat-loaded managedSingleEventis detached so any subsequentJPQL read reloads fresh DB state (the reload also picks up the notes appended later in the flush).
mergeAllhelper.AbstractTrackerPersister:assignIdnow handlesSingleEvent(in addition toTrackedEntity,EnrollmentandTrackerEvent) for pre-allocated ids.SingleEventPersister:sequenceName()now returnssingleevent_sequence(wasnull), enabling id pre-allocation.Notes
RelationshipandTEAVwrites still delegate toEntityManager; their Phase 6 JDBC replacements follow.legacy sequences
trackedentityinstance_sequence(TrackedEntity) andprograminstance_sequence(Enrollment) so all migrated entity types use sequence names matching their current entitynames.