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 d686dc5
Show file tree
Hide file tree
Showing 87 changed files with 517 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
2 changes: 1 addition & 1 deletion api/src/main/java/org/openmrs/BaseOpenmrsMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,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: 4 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,9 @@
@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")),
})
@Audited
public class Location extends BaseCustomizableMetadata<LocationAttribute> implements java.io.Serializable, Attributable<Location>, Address {

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
3 changes: 0 additions & 3 deletions api/src/main/java/org/openmrs/OrderType.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import org.openmrs.api.APIException;
import org.openmrs.api.context.Context;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
Expand All @@ -30,7 +28,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
2 changes: 1 addition & 1 deletion api/src/main/java/org/openmrs/PatientIdentifierType.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,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
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", 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", length = 1024 ))
})
public class ProviderAttributeType extends BaseAttributeType<Provider> implements AttributeType<Provider> {

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", 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
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
not-null="true" length="255" />
<property name="description" type="java.lang.String"
not-null="true" length="1000" />

<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>

<set name="memberships" cascade="all-delete-orphan,evict" lazy="true" inverse="true">
<key column="cohort_id" not-null="true"/>
Expand All @@ -52,4 +53,4 @@
</class>

</hibernate-mapping>


Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@
column="date_voided" length="19" />
<property name="voidReason" type="java.lang.String"
column="void_reason" length="255" />
<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="creator" class="User" not-null="true" />
<many-to-one name="voidedBy" class="User" column="voided_by" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
</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="retired" type="java.lang.Boolean"
column="retired" length="1" not-null="true"/>
Expand Down
Loading

0 comments on commit d686dc5

Please sign in to comment.