Hey all!
I am working on the hibernate 6.x and spring 6.x migration for core. There is one test that is failing that has me stumped so I thought another pair of eyes may help if anyone wants to take a look.
Here is my draft PR - TRUNK-6332: Hibernate 6.x and spring 6.x upgrade by k4pran · Pull Request #5062 · openmrs/openmrs-core · GitHub
The test is ObsServiceTest > shouldSaveUpdateDeleteVoidObsGroupCascades
It fails here with this
Caused by: org.h2.jdbc.JdbcSQLIntegrityConstraintViolationException: Unique index or primary key violation: "PUBLIC.CONSTRAINT_INDEX_13 ON PUBLIC.OBS(PREVIOUS_VERSION NULLS FIRST) VALUES ( /* 85 */ 82 )"; SQL statement:
insert into obs (accession_number,comments,concept_id,creator,date_created,date_voided,encounter_id,form_namespace_and_path,interpretation,location_id,obs_datetime,obs_group_id,order_id,person_id,previous_version,status,uuid,value_coded,value_coded_name_id,value_complex,value_datetime,value_drug,value_group_id,value_modifier,value_numeric,value_text,void_reason,voided,voided_by,obs_id) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,default) [23505-220]
Full logs - https://pastebin.com/fe7hGea6
A few observations I made is that after this line gets executed the oParent
variable has an id of 82 and 4 group members with ids 83, 84, 85 and 86. In the migrated code obs 82 only has 83 and 84.
I stepped through the code and it looks like both versions are following the same path (from what I can tell), and I can see 85 and 86 being created (and they are even created with obsGroup
reference to their parent 82).
When obs 82 hits this line and refreshes the obs, this is when the master code will have all 4 group members, but in the new code it remains only the 2 group members.
I haven’t noticed any docs or hibernate issues that explains it, so any ideas or help would be much appreciated!