Skip to content

Commit

Permalink
TRUNK-6274: Fix Issues with Hibernate Envers Audit Table Generation f…
Browse files Browse the repository at this point in the history
…or Specific Tables
  • Loading branch information
wikumChamith committed Oct 15, 2024
1 parent 4708c71 commit 75ce266
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 5 deletions.
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", columnDefinition = "clob")
@Column(name = "description", columnDefinition = "text")
private String description;

@ManyToOne(optional = false)
Expand Down
5 changes: 5 additions & 0 deletions api/src/main/java/org/openmrs/LocationAttributeType.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,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 @@ -30,6 +32,9 @@
@Entity
@Table(name = "location_attribute_type")
@Audited
@AttributeOverrides({
@AttributeOverride(name = "description", column = @Column(name = "description", length = 1024, columnDefinition = "varchar"))
})
public class LocationAttributeType extends BaseAttributeType<Location> implements AttributeType<Location> {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ 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", length = 65535, columnDefinition = "text")
private String datatypeConfig;

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

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<property name="name" type="java.lang.String" column="name" not-null="true" length="255" />

<property name="description" type="java.lang.String" column="description" length="65535" />
<property name="description" type="text" column="description" length="65535" />

<property name="datatypeClassname" type="java.lang.String" column="datatype" length="255" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<property name="name" type="java.lang.String" column="name" not-null="true" length="255" />

<property name="description" type="java.lang.String" column="description" length="65535" />
<property name="description" type="text" column="description" length="65535" />

<property name="datatypeClassname" type="java.lang.String" column="datatype" length="255" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,8 @@
referencedColumnNames="obs_id"/>
</changeSet>

<changeSet id="1728975219629-1" author="wikumC">
<modifyDataType tableName="diagnosis_attribute_type" columnName="description" newDataType="text" />
</changeSet>

</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ private SessionFactory buildSessionFactory() {
configuration.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "false");
configuration.setProperty(Environment.USE_QUERY_CACHE, "false");
configuration.setProperty("hibernate.integration.envers.enabled", "false");
configuration.setProperty(Environment.STORAGE_ENGINE, "InnoDB");
// Validate HBMs against the actual schema
configuration.setProperty(Environment.HBM2DDL_AUTO, "validate");

Expand Down

0 comments on commit 75ce266

Please sign in to comment.