From 4e546e2ef0137d1a3c7e6ed0a072a7003cfc938c Mon Sep 17 00:00:00 2001 From: Daniele Mams Date: Tue, 26 Mar 2024 14:00:16 +0100 Subject: [PATCH] [JBPM-10224] Missing index 'IDX_EventTypes_IdElement' with hibernate (#2395) * [JBPM-10224] Missing index 'IDX_EventTypes_IdElement' with hibernate.hbm2ddl.auto=update * [JBPM-10224] Align ddl-scripts for mysql5 and mysqlinnodb with creation of index 'IDX_EventTypes_IdElement' * [JBPM-10224] Align ddl-scripts for mysql5 and mysqlinnodb with creation of index 'IDX_EventTypes_Id' --- .../resources/db/ddl-scripts/mysql5/mysql5-jbpm-schema.sql | 4 ++-- .../mysqlinnodb/mysql-innodb-cluster-jbpm-schema.sql | 4 ++-- .../db/ddl-scripts/mysqlinnodb/mysql-innodb-jbpm-schema.sql | 4 ++-- .../db/upgrade-scripts/mysql5/jbpm-7.72-to-7.73.sql | 3 +++ .../db/upgrade-scripts/mysql5/rhpam-7.13-to-7.13.1.sql | 5 ++++- .../db/upgrade-scripts/mysqlinnodb/jbpm-7.72-to-7.73.sql | 3 +++ .../db/upgrade-scripts/mysqlinnodb/rhpam-7.13-to-7.13.1.sql | 5 ++++- .../persistence/processinstance/ProcessInstanceInfo.java | 2 +- 8 files changed, 21 insertions(+), 9 deletions(-) create mode 100644 jbpm-db-scripts/src/main/resources/db/upgrade-scripts/mysql5/jbpm-7.72-to-7.73.sql create mode 100644 jbpm-db-scripts/src/main/resources/db/upgrade-scripts/mysqlinnodb/jbpm-7.72-to-7.73.sql diff --git a/jbpm-db-scripts/src/main/resources/db/ddl-scripts/mysql5/mysql5-jbpm-schema.sql b/jbpm-db-scripts/src/main/resources/db/ddl-scripts/mysql5/mysql5-jbpm-schema.sql index 63bf983d94..f72c59f7b8 100644 --- a/jbpm-db-scripts/src/main/resources/db/ddl-scripts/mysql5/mysql5-jbpm-schema.sql +++ b/jbpm-db-scripts/src/main/resources/db/ddl-scripts/mysql5/mysql5-jbpm-schema.sql @@ -769,8 +769,8 @@ create index IDX_TaskEvent_taskId on TaskEvent (taskId); create index IDX_TaskEvent_processInstanceId on TaskEvent (processInstanceId); - create index IDX_EventTypes_element ON EventTypes(element); - create index IDX_EventTypes_compound ON EventTypes(InstanceId, element); + create index IDX_EventTypes_Id ON EventTypes(InstanceId); + create index IDX_EventTypes_IdElement ON EventTypes(InstanceId, element); create index IDX_CMI_Context ON ContextMappingInfo(CONTEXT_ID); create index IDX_CMI_KSession ON ContextMappingInfo(KSESSION_ID); diff --git a/jbpm-db-scripts/src/main/resources/db/ddl-scripts/mysqlinnodb/mysql-innodb-cluster-jbpm-schema.sql b/jbpm-db-scripts/src/main/resources/db/ddl-scripts/mysqlinnodb/mysql-innodb-cluster-jbpm-schema.sql index 173d9e42a2..e6d284abed 100644 --- a/jbpm-db-scripts/src/main/resources/db/ddl-scripts/mysqlinnodb/mysql-innodb-cluster-jbpm-schema.sql +++ b/jbpm-db-scripts/src/main/resources/db/ddl-scripts/mysqlinnodb/mysql-innodb-cluster-jbpm-schema.sql @@ -788,8 +788,8 @@ create index IDX_TaskEvent_taskId on TaskEvent (taskId); create index IDX_TaskEvent_processInstanceId on TaskEvent (processInstanceId); - create index IDX_EventTypes_element ON EventTypes(element); - create index IDX_EventTypes_compound ON EventTypes(InstanceId, element); + create index IDX_EventTypes_Id ON EventTypes(InstanceId); + create index IDX_EventTypes_IdElement ON EventTypes(InstanceId, element); create index IDX_CMI_Context ON ContextMappingInfo(CONTEXT_ID); create index IDX_CMI_KSession ON ContextMappingInfo(KSESSION_ID); diff --git a/jbpm-db-scripts/src/main/resources/db/ddl-scripts/mysqlinnodb/mysql-innodb-jbpm-schema.sql b/jbpm-db-scripts/src/main/resources/db/ddl-scripts/mysqlinnodb/mysql-innodb-jbpm-schema.sql index 62510c2a97..c28e98bc72 100644 --- a/jbpm-db-scripts/src/main/resources/db/ddl-scripts/mysqlinnodb/mysql-innodb-jbpm-schema.sql +++ b/jbpm-db-scripts/src/main/resources/db/ddl-scripts/mysqlinnodb/mysql-innodb-jbpm-schema.sql @@ -768,8 +768,8 @@ create index IDX_TaskEvent_taskId on TaskEvent (taskId); create index IDX_TaskEvent_processInstanceId on TaskEvent (processInstanceId); - create index IDX_EventTypes_element ON EventTypes(element); - create index IDX_EventTypes_compound ON EventTypes(InstanceId, element); + create index IDX_EventTypes_Id ON EventTypes(InstanceId); + create index IDX_EventTypes_IdElement ON EventTypes(InstanceId, element); create index IDX_CMI_Context ON ContextMappingInfo(CONTEXT_ID); create index IDX_CMI_KSession ON ContextMappingInfo(KSESSION_ID); diff --git a/jbpm-db-scripts/src/main/resources/db/upgrade-scripts/mysql5/jbpm-7.72-to-7.73.sql b/jbpm-db-scripts/src/main/resources/db/upgrade-scripts/mysql5/jbpm-7.72-to-7.73.sql new file mode 100644 index 0000000000..baa3eaf415 --- /dev/null +++ b/jbpm-db-scripts/src/main/resources/db/upgrade-scripts/mysql5/jbpm-7.72-to-7.73.sql @@ -0,0 +1,3 @@ +DROP INDEX IDX_EventTypes_element; +DROP INDEX IDX_EventTypes_compound; +CREATE INDEX IDX_EventTypes_IdElement ON EventTypes(InstanceId,element); \ No newline at end of file diff --git a/jbpm-db-scripts/src/main/resources/db/upgrade-scripts/mysql5/rhpam-7.13-to-7.13.1.sql b/jbpm-db-scripts/src/main/resources/db/upgrade-scripts/mysql5/rhpam-7.13-to-7.13.1.sql index 079eaf9200..1915d75d8e 100644 --- a/jbpm-db-scripts/src/main/resources/db/upgrade-scripts/mysql5/rhpam-7.13-to-7.13.1.sql +++ b/jbpm-db-scripts/src/main/resources/db/upgrade-scripts/mysql5/rhpam-7.13-to-7.13.1.sql @@ -1,2 +1,5 @@ ALTER TABLE TimerMappingInfo ADD COLUMN processInstanceId bigint; -ALTER TABLE TimerMappingInfo MODIFY timerId bigint NULL; \ No newline at end of file +ALTER TABLE TimerMappingInfo MODIFY timerId bigint NULL; +DROP INDEX IDX_EventTypes_element; +DROP INDEX IDX_EventTypes_compound; +CREATE INDEX IDX_EventTypes_IdElement ON EventTypes(InstanceId,element); \ No newline at end of file diff --git a/jbpm-db-scripts/src/main/resources/db/upgrade-scripts/mysqlinnodb/jbpm-7.72-to-7.73.sql b/jbpm-db-scripts/src/main/resources/db/upgrade-scripts/mysqlinnodb/jbpm-7.72-to-7.73.sql new file mode 100644 index 0000000000..baa3eaf415 --- /dev/null +++ b/jbpm-db-scripts/src/main/resources/db/upgrade-scripts/mysqlinnodb/jbpm-7.72-to-7.73.sql @@ -0,0 +1,3 @@ +DROP INDEX IDX_EventTypes_element; +DROP INDEX IDX_EventTypes_compound; +CREATE INDEX IDX_EventTypes_IdElement ON EventTypes(InstanceId,element); \ No newline at end of file diff --git a/jbpm-db-scripts/src/main/resources/db/upgrade-scripts/mysqlinnodb/rhpam-7.13-to-7.13.1.sql b/jbpm-db-scripts/src/main/resources/db/upgrade-scripts/mysqlinnodb/rhpam-7.13-to-7.13.1.sql index 079eaf9200..1915d75d8e 100644 --- a/jbpm-db-scripts/src/main/resources/db/upgrade-scripts/mysqlinnodb/rhpam-7.13-to-7.13.1.sql +++ b/jbpm-db-scripts/src/main/resources/db/upgrade-scripts/mysqlinnodb/rhpam-7.13-to-7.13.1.sql @@ -1,2 +1,5 @@ ALTER TABLE TimerMappingInfo ADD COLUMN processInstanceId bigint; -ALTER TABLE TimerMappingInfo MODIFY timerId bigint NULL; \ No newline at end of file +ALTER TABLE TimerMappingInfo MODIFY timerId bigint NULL; +DROP INDEX IDX_EventTypes_element; +DROP INDEX IDX_EventTypes_compound; +CREATE INDEX IDX_EventTypes_IdElement ON EventTypes(InstanceId,element); \ No newline at end of file diff --git a/jbpm-persistence/jbpm-persistence-jpa/src/main/java/org/jbpm/persistence/processinstance/ProcessInstanceInfo.java b/jbpm-persistence/jbpm-persistence-jpa/src/main/java/org/jbpm/persistence/processinstance/ProcessInstanceInfo.java index 00696764e4..b2eb22abad 100644 --- a/jbpm-persistence/jbpm-persistence-jpa/src/main/java/org/jbpm/persistence/processinstance/ProcessInstanceInfo.java +++ b/jbpm-persistence/jbpm-persistence-jpa/src/main/java/org/jbpm/persistence/processinstance/ProcessInstanceInfo.java @@ -85,7 +85,7 @@ public class ProcessInstanceInfo implements PersistentProcessInstance { @ElementCollection @CollectionTable(name="EventTypes", joinColumns=@JoinColumn(name="InstanceId"), indexes = {@Index(name = "IDX_EventTypes_Id", columnList="InstanceId"), - @Index(name = "IDX_EventTypes_element", columnList="element")}) + @Index(name = "IDX_EventTypes_IdElement", columnList="InstanceId, element")}) @Column(name="element") private Set eventTypes = new HashSet();