From 20b100b2c1e2f6499b49b239816e92fcc2013f54 Mon Sep 17 00:00:00 2001 From: Rishabh Date: Thu, 5 Dec 2024 12:49:33 +0530 Subject: [PATCH] TRUNK-5833 : ConceptDescription Domain - Switching from Hibernate Mappings to Annotations --- .../java/org/openmrs/ConceptDescription.java | 32 ++++++++++++++ api/src/main/resources/hibernate.cfg.xml | 1 - .../db/hibernate/ConceptDescription.hbm.xml | 42 ------------------- .../org/openmrs/api/OrderServiceTest.java | 1 + 4 files changed, 33 insertions(+), 43 deletions(-) delete mode 100644 api/src/main/resources/org/openmrs/api/db/hibernate/ConceptDescription.hbm.xml diff --git a/api/src/main/java/org/openmrs/ConceptDescription.java b/api/src/main/java/org/openmrs/ConceptDescription.java index dd476facdf70..5da47e4d8305 100644 --- a/api/src/main/java/org/openmrs/ConceptDescription.java +++ b/api/src/main/java/org/openmrs/ConceptDescription.java @@ -13,30 +13,62 @@ import java.util.Date; import java.util.Locale; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import org.hibernate.annotations.BatchSize; +import org.hibernate.annotations.GenericGenerator; +import org.hibernate.annotations.Parameter; /** * ConceptDescription is the localized description of a concept. */ +@Entity +@Table(name = "concept_description") +@BatchSize(size = 10) @Audited public class ConceptDescription extends BaseOpenmrsObject implements Auditable, java.io.Serializable { private static final long serialVersionUID = -7223075113369136584L; // Fields + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "concept_description_id_seq") + @GenericGenerator( + name = "concept_description_id_seq", + strategy = "native", + parameters = @Parameter(name = "sequence", value = "concept_description_concept_description_id_seq") + ) + @Column(name = "concept_description_id", nullable = false) private Integer conceptDescriptionId; + @ManyToOne + @JoinColumn(name = "concept_id", nullable = false) private Concept concept; + @Column(name = "description", length = 65535, nullable = false) private String description; + @Column(name = "locale", length = 50, nullable = false) private Locale locale; + @ManyToOne + @JoinColumn(name = "creator", nullable = false) private User creator; + @Column(name = "date_created", nullable = false) private Date dateCreated; + @ManyToOne + @JoinColumn(name = "changed_by", nullable = true) private User changedBy; + @Column(name = "date_changed", nullable = true) private Date dateChanged; // Constructors diff --git a/api/src/main/resources/hibernate.cfg.xml b/api/src/main/resources/hibernate.cfg.xml index 2bd3c6ad8dc1..df9866d6d1fd 100644 --- a/api/src/main/resources/hibernate.cfg.xml +++ b/api/src/main/resources/hibernate.cfg.xml @@ -27,7 +27,6 @@ - diff --git a/api/src/main/resources/org/openmrs/api/db/hibernate/ConceptDescription.hbm.xml b/api/src/main/resources/org/openmrs/api/db/hibernate/ConceptDescription.hbm.xml deleted file mode 100644 index d78a95c179dd..000000000000 --- a/api/src/main/resources/org/openmrs/api/db/hibernate/ConceptDescription.hbm.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - concept_description_concept_description_id_seq - - - - - - - - - - - - - - - - diff --git a/api/src/test/java/org/openmrs/api/OrderServiceTest.java b/api/src/test/java/org/openmrs/api/OrderServiceTest.java index 6d553c038256..cfde221aa6d6 100644 --- a/api/src/test/java/org/openmrs/api/OrderServiceTest.java +++ b/api/src/test/java/org/openmrs/api/OrderServiceTest.java @@ -2740,6 +2740,7 @@ public void saveOrder_shouldFailIfTheJavaTypeOfThePreviousOrderDoesNotMatch() th .addAnnotatedClass(ProgramAttributeType.class) .addAnnotatedClass(HL7InError.class) .addAnnotatedClass(OrderType.class) + .addAnnotatedClass(ConceptDescription.class) .getMetadataBuilder().build();