Skip to content

Commit

Permalink
TRUNK-6276: Fix ValidateHibernateMappingsDatabaseIT test errors when …
Browse files Browse the repository at this point in the history
…running with MySQL
  • Loading branch information
wikumChamith committed Oct 29, 2024
1 parent 335c2b5 commit 1624f24
Show file tree
Hide file tree
Showing 91 changed files with 529 additions and 279 deletions.
133 changes: 77 additions & 56 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,63 +3,84 @@ name: Build with Maven

# trigger build on branches that *should* support both Java 8 and Java 11
on:
push:
branches:
- master
- 2.4.x
- 2.5.x
- 2.6.x
pull_request:
branches:
- master
- 2.4.x
- 2.5.x
- 2.6.x
workflow_dispatch:
push:
branches:
- master
- 2.4.x
- 2.5.x
- 2.6.x
pull_request:
branches:
- master
- 2.4.x
- 2.5.x
- 2.6.x
workflow_dispatch:

permissions: read-all

jobs:
build:
strategy:
matrix:
platform:
- ubuntu-latest
java-version:
- 8
- 11
- 17
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: ${{ matrix.java-version }}
cache: 'maven'
- name: Install dependencies
run: mvn clean install -DskipTests=true -Dmaven.javadoc.skip=true --batch-mode --show-version --file pom.xml
- name: Build with Maven
run: mvn clean install --batch-mode && mvn test -Pskip-default-test -Pintegration-test --batch-mode --file pom.xml
# this is necessary to populate the environment variables for Coveralls properly
- name: Set branch name and PR number
id: refs
if: ${{ matrix.java-version == '8' }}
continue-on-error: true
env:
BRANCH_NAME_OR_REF: ${{ github.head_ref || github.ref }}
run: |
echo "::set-output name=branch_name::${BRANCH_NAME_OR_REF#refs/heads/}"
echo "::set-output name=pr_number::$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")"
- name: Update coverage data
# only send coverage data for Java 8
if: ${{ matrix.java-version == '8' && steps.refs.outcome == 'success' }}
continue-on-error: true
env:
CI_NAME: Github
CI_BUILD_NUMBER: ${{ github.run_id }}
CI_BUILD_URL: https://github.com/${{ github.repository }}/commit/${{ github.event.after }}/checks
CI_BRANCH: ${{ steps.refs.outputs.branch_name }}
CI_PULL_REQUEST: ${{ steps.refs.outputs.pr_number }}
run: mvn jacoco:report coveralls:report --batch-mode --file pom.xml --no-transfer-progress -DrepoToken=${{ secrets.COVERALLS_TOKEN }}
build:
strategy:
matrix:
platform:
- ubuntu-latest
java-version:
- 8
- 11
- 17
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: ${{ matrix.java-version }}
cache: 'maven'
- name: Install dependencies
run: mvn clean install -DskipTests=true -Dmaven.javadoc.skip=true --batch-mode --show-version --file pom.xml
- name: Build with Maven
run: mvn clean install --batch-mode && mvn test -Pskip-default-test -Pintegration-test --batch-mode --file pom.xml
# this is necessary to populate the environment variables for Coveralls properly
- name: Set branch name and PR number
id: refs
if: ${{ matrix.java-version == '8' }}
continue-on-error: true
env:
BRANCH_NAME_OR_REF: ${{ github.head_ref || github.ref }}
run: |
echo "::set-output name=branch_name::${BRANCH_NAME_OR_REF#refs/heads/}"
echo "::set-output name=pr_number::$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")"
- name: Update coverage data
# only send coverage data for Java 8
if: ${{ matrix.java-version == '8' && steps.refs.outcome == 'success' }}
continue-on-error: true
env:
CI_NAME: Github
CI_BUILD_NUMBER: ${{ github.run_id }}
CI_BUILD_URL: https://github.com/${{ github.repository }}/commit/${{ github.event.after }}/checks
CI_BRANCH: ${{ steps.refs.outputs.branch_name }}
CI_PULL_REQUEST: ${{ steps.refs.outputs.pr_number }}
run: mvn jacoco:report coveralls:report --batch-mode --file pom.xml --no-transfer-progress -DrepoToken=${{ secrets.COVERALLS_TOKEN }}

build_with_mysql:
strategy:
matrix:
platform:
- ubuntu-latest
java-version:
- 8
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: ${{ matrix.java-version }}
cache: 'maven'
- name: Install dependencies
run: mvn clean install -DskipTests=true -Dmaven.javadoc.skip=true --batch-mode --show-version --file pom.xml
- name: Build with Maven with external database
run: mvn clean install --batch-mode && mvn test -DuseInMemoryDatabase=false -Pskip-default-test -Pintegration-test --batch-mode --file pom.xml
3 changes: 2 additions & 1 deletion api/src/main/java/org/openmrs/BaseOpenmrsMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import javax.persistence.Column;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;

Expand All @@ -38,7 +39,7 @@ public abstract class BaseOpenmrsMetadata extends BaseOpenmrsObject implements O
@Field
private String name;

@Column(name = "description", length = 255)
@Column(name = "description")
private String description;

@ManyToOne(optional = false)
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/org/openmrs/BaseOpenmrsObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
@Audited
public abstract class BaseOpenmrsObject implements Serializable, OpenmrsObject {

@Column(name = "uuid", unique = true, nullable = false, length = 38, updatable = false)
@Column(name = "uuid", unique = true, nullable = false, length = 38, updatable = false, columnDefinition = "char")
private String uuid = UUID.randomUUID().toString();

/**
Expand Down
5 changes: 5 additions & 0 deletions api/src/main/java/org/openmrs/ConceptMapType.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import org.codehaus.jackson.annotate.JsonIgnore;
import org.hibernate.envers.Audited;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
Expand All @@ -28,6 +30,9 @@
@Entity
@Table(name = "concept_map_type")
@Audited
@AttributeOverrides(value = {
@AttributeOverride(name = "description", column = @Column(name = "description", columnDefinition = "varchar(255)", length = 255)),
})
public class ConceptMapType extends BaseChangeableOpenmrsMetadata {

private static final long serialVersionUID = 1L;
Expand Down
6 changes: 5 additions & 1 deletion api/src/main/java/org/openmrs/Location.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.openmrs.api.context.Context;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
Expand Down Expand Up @@ -47,7 +48,10 @@
@Entity
@Table(name = "location")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@AttributeOverride(name = "attributes", column = @Column(name = "location_id"))
@AttributeOverrides(value = {
@AttributeOverride(name = "attributes", column = @Column(name = "location_id")),
@AttributeOverride(name = "description", column = @Column(name = "description", columnDefinition = "varchar(255)", length = 255))
})
@Audited
public class Location extends BaseCustomizableMetadata<LocationAttribute> implements java.io.Serializable, Attributable<Location>, Address {

Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/org/openmrs/LocationAttributeType.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
@Table(name = "location_attribute_type")
@Audited
@AttributeOverrides(value = {
@AttributeOverride(name = "description", column = @Column(name = "description", length = 1024))
@AttributeOverride(name = "description", column = @Column(name = "description", length = 1024, columnDefinition = "varchar(1024)"))
})
public class LocationAttributeType extends BaseAttributeType<Location> implements AttributeType<Location> {

Expand Down
4 changes: 3 additions & 1 deletion api/src/main/java/org/openmrs/MedicationDispense.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
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 java.util.Date;
Expand Down Expand Up @@ -191,7 +192,8 @@ public class MedicationDispense extends BaseFormRecordableOpenmrsData {
* FHIR:DosageInstructions.patientInstructions
* Relates to drugOrder.dosingInstructions
*/
@Column(name = "dosing_instructions", length=65535)
@Column(name = "dosing_instructions", columnDefinition = "text")
@Lob
private String dosingInstructions;

/**
Expand Down
1 change: 0 additions & 1 deletion api/src/main/java/org/openmrs/OrderType.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.Set;

Expand Down
3 changes: 2 additions & 1 deletion api/src/main/java/org/openmrs/PatientIdentifierType.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
package org.openmrs;

import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.units.qual.C;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.envers.Audited;
import org.hibernate.search.annotations.DocumentId;
Expand All @@ -32,7 +33,7 @@
@Table(name = "patient_identifier_type")
@Audited
@AttributeOverrides({
@AttributeOverride(name = "name", column = @Column(name = "name", nullable = false, length = 50))
@AttributeOverride(name = "name", column = @Column(name = "name", nullable = false, length = 50)),
})
public class PatientIdentifierType extends BaseChangeableOpenmrsMetadata {

Expand Down
2 changes: 2 additions & 0 deletions api/src/main/java/org/openmrs/PersonAttributeType.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import org.hibernate.search.annotations.Field;
import org.openmrs.util.OpenmrsUtil;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
Expand Down
5 changes: 5 additions & 0 deletions api/src/main/java/org/openmrs/ProgramAttributeType.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import org.openmrs.attribute.AttributeType;
import org.openmrs.attribute.BaseAttributeType;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
Expand All @@ -26,6 +28,9 @@
@Entity
@Table(name = "program_attribute_type")
@Audited
@AttributeOverrides(value = {
@AttributeOverride(name = "description", column = @Column(name = "description", columnDefinition = "varchar(1024)", length = 1024))
})
public class ProgramAttributeType extends BaseAttributeType<PatientProgram> implements AttributeType<PatientProgram> {

@Id
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/org/openmrs/ProviderAttributeType.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
@Table(name = "provider_attribute_type")
@Audited
@AttributeOverrides(value = {
@AttributeOverride(name = "description", column = @Column(name = "description", length = 1024))
@AttributeOverride(name = "description", column = @Column(name = "description", columnDefinition = "varchar(1024)", length = 1024 ))
})
public class ProviderAttributeType extends BaseAttributeType<Provider> implements AttributeType<Provider> {

Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/org/openmrs/VisitAttributeType.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
@Table(name = "visit_attribute_type")
@Audited
@AttributeOverrides(value = {
@AttributeOverride(name = "description", column = @Column(name = "description", length = 1024))
@AttributeOverride(name = "description", column = @Column(name = "description", columnDefinition = "varchar(1024)", length = 1024))
})
public class VisitAttributeType extends BaseAttributeType<Visit> implements AttributeType<Visit> {

Expand Down
9 changes: 8 additions & 1 deletion api/src/main/java/org/openmrs/api/db/SerializedObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@
import org.openmrs.BaseChangeableOpenmrsMetadata;
import org.openmrs.serialization.OpenmrsSerializer;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;

/**
Expand All @@ -28,6 +31,9 @@
@Entity
@Table(name = "serialized_object")
@Audited
@AttributeOverrides(value = {
@AttributeOverride(name = "description", column = @Column(name = "description", columnDefinition = "varchar(1024)", length = 5000))
})
public class SerializedObject extends BaseChangeableOpenmrsMetadata {

@Id
Expand All @@ -49,7 +55,8 @@ public class SerializedObject extends BaseChangeableOpenmrsMetadata {
@Column(name = "serialization_class", nullable = false, length = 255)
private Class<? extends OpenmrsSerializer> serializationClass;

@Column(name = "serialized_data", length = 16777215)
@Column(name = "serialized_data", columnDefinition = "mediumtext")
@Lob
private String serializedData;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ public abstract class BaseAttributeType<OwningType extends Customizable<?>> exte
@Column(name = "datatype", length = 255)
private String datatypeClassname;

@Column(name = "datatype_config", length = 65535 )
@Column(name = "datatype_config", columnDefinition = "text")
@Lob
private String datatypeConfig;

@Column(name = "preferred_handler", length = 255)
private String preferredHandlerClassname;

@Column(name = "handler_config", length = 65535 )
@Column(name = "handler_config", columnDefinition = "text")
@Lob
private String handlerConfig;

Expand Down
3 changes: 2 additions & 1 deletion api/src/main/java/org/openmrs/hl7/HL7QueueItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public abstract class HL7QueueItem extends BaseOpenmrsObject {
@JoinColumn(name = "hl7_source")
private HL7Source hl7Source;

@Column(name = "hl7_source_key", length = 1024)
@Column(name = "hl7_source_key", columnDefinition = "text")
@Lob
private String hl7SourceKey;

@Column(name = "hl7_data", nullable = false, columnDefinition = "text")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
<many-to-one name="allergy" class="Allergy" column="allergy_id" not-null="true"/>
<many-to-one name="reaction" column="reaction_concept_id" class="org.openmrs.Concept" not-null="true"/>
<property name="reactionNonCoded" type="java.lang.String" column="reaction_non_coded"/>
<property name="uuid" type="java.lang.String" column="uuid" length="38" unique="true" not-null="true"/>
<property name="uuid" type="java.lang.String" unique="true" not-null="true">
<column name="uuid" sql-type="char(38)" />
</property>
</class>
</hibernate-mapping>
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@
column="date_created" not-null="true" length="19" />
<many-to-one name="creator" class="org.openmrs.User"
not-null="true" />
<property name="uuid" type="java.lang.String"
column="uuid" length="38" unique="true" />
<property name="uuid" type="java.lang.String" unique="true">
<column name="uuid" sql-type="char(38)" />
</property>
<many-to-one name="retiredBy" class="org.openmrs.User"
column="retired_by" />
<property name="dateRetired" type="java.util.Date"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
<param name="sequence">clob_datatype_storage_id_seq</param>
</generator>
</id>

<property name="uuid" type="java.lang.String" column="uuid" length="38" unique="true" />
<property name="uuid" type="java.lang.String" unique="true">
<column name="uuid" sql-type="char(38)" />
</property>
<property name="value" type="materialized_clob" column="value" />

</class>
Expand Down
Loading

0 comments on commit 1624f24

Please sign in to comment.