GSoC-2020: Switching from XML Mappings to Annotations on OpenMRS domain Objects

@alinmihaila99, I’m not sure there exists any work done for such use case. Basically you want to leverage the annotation @Inheritance(strategy = InheritanceType.JOINED) on the Order entity and going ahead to annotate the subclasses with @Entity then annotating the rest of the domains’ properties accordingly.

Hi @ruhanga, I tried to run ValidateHibernateMappingsDatabaseIT from IntellIJ and this time it failed for class ProgramWorkflowState, I don’t know why when I ran the commmand in terminal it passed. The error message was:

org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing column [date_retired] in table [program_workflow_state]

@alinmihaila99, you could employ the advise given by @ibacher to address this for fields unknown to the appropriate liquibase changeset.

In this case, you might have to do something like

@Transient
@Override
public Date getDateRetired() {
		return super.getDateRetired;
}

I believe this would be opportunity to address issues have since risen when switching to annotation from hibernate mappings.

@alinmihaila99, for these changesets you could refer to this .

Hi @ruhanga, I tried to use @Override and @Transient to resolve the missing columns for the class CohortMembership but I still have the missing columns error. This is what I tried to do. Is it something I miss?

And one more question @ruhanga . ConceptReferenceTermMap and ConceptMap both extends ConceptBaseMap and in their mapping there is the mapping for the superclass, but there are some columns that are different. How should I annotate the class ConceptBaseMap? Should I use @AttributeOverride to override the column that is not the same as in ConceptMap?

@alinmihaila99, do you have atleast a draft PR to look at?

Hoping that you are referring to BaseConceptMap yes. You will want to do something along the following lines, where in the end you’d annotate the common fields in the base class and where necessary override them in the subclasses:

@MappedSuperclass
public abstract class BaseConceptMap extends BaseOpenmrsObject implements Auditable {
     ....
     ....
}

and

@Entity
@Table(..)
// Where necessary: @AttributeOverride(...)
public class ConceptReferenceTermMap extends BaseConceptMap {
    ....
}
@Entity
@Table(..)
// Where necessary: @AttributeOverride(...)
public class ConceptMap extends BaseConceptMap {
    ....
}

I’m not sure why BaseConceptMap was annotated like all the other BaseOpenmrs* @MappedSuperclasss.

@dkayiwa, @ibacher, @mogoodrich, @wyclif, do you know and/or do you have any preference on this?

@ruhanga i did this but travis failed for 1 check. Can you have a look at the PR?

I could not locate any PR on CohortMembership. Could you share a link to it if any?

Sure. https://github.com/openmrs/openmrs-core/pull/3453

Hi @ruhanga, I had a problem after removing the bin files from the PR’s. After doing this the security snyk failed. Here is one PR I talk about. Can you have a look, please?

@alinmihaila99, I’ve left a comment on the PR. Thanks for the observation.

Hi @ruhanga, can you have a look at this travis log please? I really don’t know what happend.

Hi @alinmihaila99, I left a comment on the PR.

1 Like

Hi @ruhanga, I had an error similar to that one from this travis log. Can you have a look, please?

@alinmihaila99, I left a comment on the PR.