Skip to content

TRUNK-5899: Replace Hibernate XML mapping with JPA annotations for ConceptAttributeType #5008

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alexdev2026
Copy link

TRUNK-5899: Replace Hibernate XML mapping with JPA annotations for ConceptAttributeType

Description of what I changed

  • Replaced Hibernate XML mapping in ConceptAttributeType with JPA Annotations
  • Removed related Hibernate XML mapping files to ConceptAttributeType class
  • Added unit test ConceptAttributeTypeTest to ensure ConceptAttributeType with JPA Annotations was functioning properly
  • Used full unit test suite to confirm safe functionality as master branch

Issue I worked on

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

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.

@@ -26,7 +26,7 @@
<mapping resource="org/openmrs/api/db/hibernate/Concept.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/ConceptAnswer.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/ConceptAttribute.hbm.xml" />
<mapping resource="org/openmrs/api/db/hibernate/ConceptAttributeType.hbm.xml" />
<!-- <mapping resource="org/openmrs/api/db/hibernate/ConceptAttributeType.hbm.xml" /> -->
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<!-- <mapping resource="org/openmrs/api/db/hibernate/ConceptAttributeType.hbm.xml" /> -->

Copy link
Author

Choose a reason for hiding this comment

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

I added this change into my updated pull request. Thank you for the suggestion!

api/pom.xml Outdated
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
<version>2.2.3</version>
</dependency>
Copy link
Member

Choose a reason for hiding this comment

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

struggling to understand this change, care to explain?

Copy link
Author

Choose a reason for hiding this comment

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

Absolutely! This dependency was added to ensure that the JPA (Jakarta Persistence API) annotations maintain compatibility with current Java versions supported by OpenMRS. Since Java 8 is the current baseline requirement for OpenMRS 2.x, I chose JPA dependency version 2.2.3 as it is the last version compatible with Java 8. This allows the JPA annotations to be added to the ConceptAttributeType domain class without needing to upgrade the whole codebase to Java 11+.

Copy link
Member

Choose a reason for hiding this comment

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

I dont see where youre using that library in your changes

Copy link
Author

Choose a reason for hiding this comment

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

The addition of the JPA dependency version 2.2.3 supports the JPA annotations "@id", "@GeneratedValue", and "@column" that you can see in the updated ConceptAttributeType class, which are replacing the XML mappings as described in task TRUNK-5899.

Copy link
Member

@mherman22 mherman22 Apr 21, 2025

Choose a reason for hiding this comment

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

but those ones are being imported by javax.persistence.Id; and javax.persistence.Column; which are not coming from the dependency you have added above.

Copy link
Author

Choose a reason for hiding this comment

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

I see. You are correct. Jakarta is the modernized version of javax, but does not contain the javax.persistence packages that I imported. I tested my changes both with and without the jakarta.persistence dependency, and it works correctly in both. I will update my pull request to reflect this change. Thank you for pointing this out!

Copy link
Author

Choose a reason for hiding this comment

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

This dependency is now removed in my updated pull request. My update still passes all new and existing unit tests. Thank you for your help and review!

Copy link
Member

Choose a reason for hiding this comment

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

If you feel like jumping into that kind of work of moving stuff from javax to jakarta, feel free to create a ticket on jira and geek yourself away 🥲

Copy link
Author

Choose a reason for hiding this comment

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

I will definitely create a ticket! Anything other clarifications or changes you would recommend for this task?

…nceptAttributeType

 - add source code form to ConceptAttributeTypeTest.java
 - removed jakarta.persistence dependency in pom.xml based on code review
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