diff --git a/api/src/main/java/org/openmrs/Field.java b/api/src/main/java/org/openmrs/Field.java index d7049655774..b225c675e89 100644 --- a/api/src/main/java/org/openmrs/Field.java +++ b/api/src/main/java/org/openmrs/Field.java @@ -13,34 +13,66 @@ import java.util.Set; import org.codehaus.jackson.annotate.JsonIgnore; +import org.hibernate.annotations.GenericGenerator; +import org.hibernate.annotations.Parameter; 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.JoinColumn; +import javax.persistence.Lob; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.persistence.Transient; + /** * Field * * @version 1.0 */ +@Entity +@Table(name = "field") @Audited public class Field extends BaseChangeableOpenmrsMetadata { public static final long serialVersionUID = 4454L; // Fields - + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "field_id_seq") + @GenericGenerator( + name = "field_id_seq", + strategy = "native", + parameters = @Parameter(name = "sequence", value = "field_field_id_seq") + ) + @Column(name = "field_id") private Integer fieldId; - + + @ManyToOne + @JoinColumn(name = "field_type") private FieldType fieldType; - + + @ManyToOne + @JoinColumn(name = "concept_id") private Concept concept; - + + @Column(name = "table_name", length = 50) private String tableName; + @Column(name = "attribute_name", length = 50) private String attributeName; - + + @Column(name = "default_value", columnDefinition = "TEXT") + @Lob private String defaultValue; - + + @Column(name = "select_multiple", length = 1, nullable = false) private Boolean selectMultiple = false; + @Transient private Set answers; // Constructors diff --git a/api/src/main/resources/hibernate.cfg.xml b/api/src/main/resources/hibernate.cfg.xml index 2bd3c6ad8dc..71d7335c6ac 100644 --- a/api/src/main/resources/hibernate.cfg.xml +++ b/api/src/main/resources/hibernate.cfg.xml @@ -44,7 +44,6 @@ - diff --git a/api/src/main/resources/org/openmrs/api/db/hibernate/Field.hbm.xml b/api/src/main/resources/org/openmrs/api/db/hibernate/Field.hbm.xml deleted file mode 100644 index 2be5c7bed17..00000000000 --- a/api/src/main/resources/org/openmrs/api/db/hibernate/Field.hbm.xml +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - - field_field_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..a363187c2ff 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(org.openmrs.Field.class) .getMetadataBuilder().build();