Skip to content

Conversation

@shivvani-r
Copy link

@shivvani-r shivvani-r commented Dec 6, 2025

Description of what I changed

I have migrated the CohortMembership domain object from legacy Hibernate XML mappings to standard JPA annotations.

Specific changes include:

  • Added JPA annotations (@Entity, @Table, @Column, etc.) to CohortMembership.java.
  • Implemented the ID mapping using the standard GenerationType.IDENTITY strategy.
  • Schema Compatibility: Used @AttributeOverride and @AssociationOverride to map the inherited dateChanged and changedBy fields to date_created and creator (read-only). This resolves schema validation errors because the legacy cohort_member table lacks modification tracking columns.
  • Deleted the obsolete CohortMembership.hbm.xml file.
  • Updated hibernate.cfg.xml to reference the annotated class instead of the XML resource.

Issue I worked on

see https://issues.openmrs.org/browse/TRUNK-5902

Checklist: I completed these to help reviewers :)

  • My IDE is configured to follow the code style of this project.

  • I have added tests to cover my changes. (If you refactored existing code that was well tested you do not have to add tests)

  • I ran mvn clean package right before creating this pull request and added all formatting changes to my commit.

  • All new and existing tests passed.

  • My pull request is based on the latest changes of the master branch.

@Id
@Column(name = "cohort_member_id")
@GeneratedValue(generator = "native")
@GenericGenerator(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pointer! I've switched it to GenerationType.IDENTITY and confirmed that the tests still pass.

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.

2 participants