-
Notifications
You must be signed in to change notification settings - Fork 4.1k
TRUNK-5950: RelationshipType Domain - Switching from Hibernate Mappings to Annotations #5570
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,10 @@ | |
| */ | ||
| package org.openmrs; | ||
|
|
||
| import jakarta.persistence.*; | ||
| import org.codehaus.jackson.annotate.JsonIgnore; | ||
| import org.hibernate.annotations.GenericGenerator; | ||
| import org.hibernate.annotations.Parameter; | ||
| import org.hibernate.envers.Audited; | ||
|
|
||
| /** | ||
|
|
@@ -33,21 +36,32 @@ | |
| * In English, we run into a tricky RelationshipType with aunts and uncles. We have chosen to define | ||
| * them as aunt/uncle-niece/nephew. | ||
| */ | ||
| @Entity | ||
| @Table (name = "relationship_type") | ||
| @Audited | ||
| @AttributeOverride(name = "name", column = @Column(name = "name", nullable = true)) | ||
| public class RelationshipType extends BaseChangeableOpenmrsMetadata{ | ||
|
|
||
| public static final long serialVersionUID = 4223L; | ||
|
|
||
| // Fields | ||
|
|
||
| @Id | ||
| @Column(name = "relationship_type_id") | ||
| @GeneratedValue(generator = "native") | ||
| @GenericGenerator(name = "native", strategy = "native", parameters = { | ||
|
||
| @Parameter(name = "sequence", value = "relationship_type_relationship_type_id_seq") }) | ||
| private Integer relationshipTypeId; | ||
|
|
||
| @Column(name = "a_is_to_b", nullable = false, length = 50) | ||
| private String aIsToB; | ||
|
|
||
| @Column (name = "b_is_to_a", nullable = false, length = 50) | ||
| private String bIsToA; | ||
|
|
||
| @Column (nullable = false) | ||
| private Integer weight = 0; | ||
|
|
||
| @Column (nullable = false) | ||
| private Boolean preferred = false; | ||
|
|
||
| // Constructors | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,7 +39,6 @@ | |
| <mapping resource="org/openmrs/api/db/hibernate/Role.hbm.xml" /> | ||
| <mapping resource="org/openmrs/api/db/hibernate/Patient.hbm.xml" /> | ||
| <mapping resource="org/openmrs/api/db/hibernate/PatientProgramAttribute.hbm.xml" /> | ||
| <mapping resource="org/openmrs/api/db/hibernate/RelationshipType.hbm.xml" /> | ||
| <mapping resource="org/openmrs/api/db/hibernate/Order.hbm.xml" /> | ||
| <mapping resource="org/openmrs/api/db/hibernate/OrderAttribute.hbm.xml" /> | ||
| <mapping resource="org/openmrs/api/db/hibernate/OrderAttributeType.hbm.xml" /> | ||
|
|
@@ -75,6 +74,8 @@ | |
| <!-- These mappings are required because of references in Obs & Concept --> | ||
| <mapping class="org.openmrs.ObsReferenceRange"/> | ||
| <mapping class="org.openmrs.ConceptReferenceRange"/> | ||
|
|
||
| <mapping class="org.openmrs.RelationshipType"/> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shivvani-r Is this necessary, |
||
| </session-factory> | ||
|
|
||
| </hibernate-configuration> | ||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://openmrs.atlassian.net/wiki/spaces/docs/pages/25477044/Java+Conventions#Do-not-use-wildcard-imports
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have fixed the wildcard imports (my IDE settings were overriding the style guide).
I also updated the PR to resolve the schema validation failure seen in the previous build. Fix: I used @AttributeOverride to map the inherited mandatory name field to the existing a_is_to_b column. I marked it as insertable=false, updatable=false so it acts as a read-only placeholder, which satisfies the validation check without conflicting with the actual data.