diff --git a/api/src/main/java/org/openmrs/EncounterRole.java b/api/src/main/java/org/openmrs/EncounterRole.java index 0d3f7564cac..d69d6cf6f7a 100644 --- a/api/src/main/java/org/openmrs/EncounterRole.java +++ b/api/src/main/java/org/openmrs/EncounterRole.java @@ -10,6 +10,15 @@ package org.openmrs; import org.hibernate.envers.Audited; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; +import org.hibernate.annotations.BatchSize; +import org.hibernate.annotations.GenericGenerator; +import org.hibernate.annotations.Parameter; /** * An EncounterRole a role specific to the encounter. While these could match up to existing @@ -17,12 +26,23 @@ * * @since 1.9 */ +@Entity +@Table(name = "encounter_role") +@BatchSize(size = 25) @Audited public class EncounterRole extends BaseChangeableOpenmrsMetadata { public static final String UNKNOWN_ENCOUNTER_ROLE_UUID = "a0b03050-c99b-11e0-9572-0800200c9a66"; // Fields + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "encounter_role_id_seq") + @GenericGenerator( + name = "encounter_role_id_seq", + strategy = "native", + parameters = @Parameter(name = "sequence", value = "encounter_role_encounter_role_id_seq") + ) + @Column(name = "encounter_role_id", nullable = false) private Integer encounterRoleId; // Constructors diff --git a/api/src/main/resources/hibernate.cfg.xml b/api/src/main/resources/hibernate.cfg.xml index 2bd3c6ad8dc..ccb05824184 100644 --- a/api/src/main/resources/hibernate.cfg.xml +++ b/api/src/main/resources/hibernate.cfg.xml @@ -78,7 +78,6 @@ - diff --git a/api/src/main/resources/org/openmrs/api/db/hibernate/EncounterRole.hbm.xml b/api/src/main/resources/org/openmrs/api/db/hibernate/EncounterRole.hbm.xml deleted file mode 100644 index f77c87b7553..00000000000 --- a/api/src/main/resources/org/openmrs/api/db/hibernate/EncounterRole.hbm.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - encounter_role_encounter_role_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 6d553c03825..a9591726818 100644 --- a/api/src/test/java/org/openmrs/api/OrderServiceTest.java +++ b/api/src/test/java/org/openmrs/api/OrderServiceTest.java @@ -35,6 +35,7 @@ import org.openmrs.DrugIngredient; import org.openmrs.DrugOrder; import org.openmrs.Encounter; +import org.openmrs.EncounterRole; import org.openmrs.FreeTextDosingInstructions; import org.openmrs.GlobalProperty; import org.openmrs.Location; @@ -2740,6 +2741,7 @@ public void saveOrder_shouldFailIfTheJavaTypeOfThePreviousOrderDoesNotMatch() th .addAnnotatedClass(ProgramAttributeType.class) .addAnnotatedClass(HL7InError.class) .addAnnotatedClass(OrderType.class) + .addAnnotatedClass(EncounterRole.class) .getMetadataBuilder().build();