Skip to content

Commit

Permalink
made fields immutable, combined SQL scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
zambrovski committed Jun 18, 2024
1 parent b9b74c8 commit bcb0944
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ class DataEntryEntity(
var correlations: MutableSet<DataEntryId> = mutableSetOf(),
@Immutable
@OneToMany(fetch = FetchType.LAZY)
@JoinColumns(JoinColumn(name = "ENTRY_TYPE", referencedColumnName = "ENTRY_TYPE"), JoinColumn(name = "ENTRY_ID", referencedColumnName = "ENTRY_ID"))
val payloadAndCorrelatedPayloadAttributes: Set<DataEntryPayloadAttributeEntity>? = 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<DataEntryPayloadAttributeEntity> = mutableSetOf(),

@Column(name = "PAYLOAD")
@Lob
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -21,5 +23,7 @@ class DataEntryPayloadAttributeEntity(
value = value
)
)

override fun toString(): String = "DataEntryPayloadAttributeEntity(id=$id)"
}

Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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)
);

0 comments on commit bcb0944

Please sign in to comment.