diff --git a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryEntity.kt b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryEntity.kt index 970e123a6..c220aeaf6 100644 --- a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryEntity.kt +++ b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryEntity.kt @@ -74,8 +74,11 @@ class DataEntryEntity( var correlations: MutableSet = mutableSetOf(), @Immutable @OneToMany(fetch = FetchType.LAZY) - @JoinColumns(JoinColumn(name = "ENTRY_TYPE", referencedColumnName = "ENTRY_TYPE"), JoinColumn(name = "ENTRY_ID", referencedColumnName = "ENTRY_ID")) - val payloadAndCorrelatedPayloadAttributes: Set? = null, + @JoinColumns( + JoinColumn(name = "ENTRY_TYPE", referencedColumnName = "ENTRY_TYPE", insertable = false, updatable = false), + JoinColumn(name = "ENTRY_ID", referencedColumnName = "ENTRY_ID", insertable = false, updatable = false) + ) + var payloadAndCorrelatedPayloadAttributes: MutableSet = mutableSetOf(), @Column(name = "PAYLOAD") @Lob diff --git a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryPayloadAttributeEntity.kt b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryPayloadAttributeEntity.kt index d9a8a9f5a..8e29eaf7d 100644 --- a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryPayloadAttributeEntity.kt +++ b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryPayloadAttributeEntity.kt @@ -3,11 +3,13 @@ package io.holunda.polyflow.view.jpa.data import jakarta.persistence.EmbeddedId import jakarta.persistence.Entity import jakarta.persistence.Table +import org.hibernate.annotations.Immutable /** * Entity that holds the combined payload attributes of the correlated DataEntries. */ @Entity +@Immutable @Table(name = "PLF_VIEW_DATA_ENTRY_PAYLOAD") class DataEntryPayloadAttributeEntity( @EmbeddedId @@ -21,5 +23,7 @@ class DataEntryPayloadAttributeEntity( value = value ) ) + + override fun toString(): String = "DataEntryPayloadAttributeEntity(id=$id)" } diff --git a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryPayloadAttributeEntityId.kt b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryPayloadAttributeEntityId.kt index d3c15135f..3524c3a03 100644 --- a/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryPayloadAttributeEntityId.kt +++ b/view/jpa/src/main/kotlin/io/holunda/polyflow/view/jpa/data/DataEntryPayloadAttributeEntityId.kt @@ -2,20 +2,22 @@ package io.holunda.polyflow.view.jpa.data import jakarta.persistence.Column import jakarta.persistence.Embeddable +import org.hibernate.annotations.Immutable import java.io.Serializable /** * Id class that holds the combined payload attributes of the correlated DataEntries. */ @Embeddable +@Immutable class DataEntryPayloadAttributeEntityId( - @Column(name = "ENTRY_TYPE", length = 64, nullable = false) + @Column(name = "ENTRY_TYPE", length = 64, nullable = false, updatable = false, insertable = false) var entryType: String, - @Column(name = "ENTRY_ID", length = 64, nullable = false) + @Column(name = "ENTRY_ID", length = 64, nullable = false, updatable = false, insertable = false) var entryId: String, - @Column(name = "PATH", nullable = false) + @Column(name = "PATH", nullable = false, updatable = false, insertable = false) var path: String, - @Column(name = "VALUE", nullable = false) + @Column(name = "VALUE", nullable = false, updatable = false, insertable = false) var value: String ) : Serializable { diff --git a/view/jpa/src/test/resources/db/migrations/h2-postgresql/V0_0_16__jpa_plf_data_entry_correlations.sql b/view/jpa/src/test/resources/db/migrations/h2-postgresql/V0_0_16__jpa_plf_data_entry_correlations.sql index 80d479c19..d70396fd7 100644 --- a/view/jpa/src/test/resources/db/migrations/h2-postgresql/V0_0_16__jpa_plf_data_entry_correlations.sql +++ b/view/jpa/src/test/resources/db/migrations/h2-postgresql/V0_0_16__jpa_plf_data_entry_correlations.sql @@ -1,4 +1,4 @@ -create table plf_data_entry_correlations +create table PLF_DATA_ENTRY_CORRELATIONS ( OWNING_ENTRY_TYPE varchar(255) not null, OWNING_ENTRY_ID varchar(64) not null, @@ -7,3 +7,17 @@ create table plf_data_entry_correlations primary key (OWNING_ENTRY_TYPE, OWNING_ENTRY_ID, ENTRY_TYPE, ENTRY_ID) ); +create view PLF_VIEW_DATA_ENTRY_PAYLOAD as +( +select * +from PLF_DATA_ENTRY_PAYLOAD_ATTRIBUTES +union +(select ec.OWNING_ENTRY_ID as ENTRY_ID, + ec.OWNING_ENTRY_TYPE as ENTRY_TYPE, + ep.path as PATH, + ep.value as VALUE + from PLF_DATA_ENTRY_CORRELATIONS ec + join PLF_DATA_ENTRY_PAYLOAD_ATTRIBUTES ep + on + ec.ENTRY_ID = ep.ENTRY_ID and ec.ENTRY_TYPE = ep.ENTRY_TYPE) +);