diff --git a/addons/common/persistence/jdbc/src/main/java/org/kie/kogito/persistence/jdbc/correlation/PostgreSQLCorrelationRepository.java b/addons/common/persistence/jdbc/src/main/java/org/kie/kogito/persistence/jdbc/correlation/JDBCCorrelationRepository.java similarity index 97% rename from addons/common/persistence/jdbc/src/main/java/org/kie/kogito/persistence/jdbc/correlation/PostgreSQLCorrelationRepository.java rename to addons/common/persistence/jdbc/src/main/java/org/kie/kogito/persistence/jdbc/correlation/JDBCCorrelationRepository.java index 1d540705b7d..eeebcda9016 100644 --- a/addons/common/persistence/jdbc/src/main/java/org/kie/kogito/persistence/jdbc/correlation/PostgreSQLCorrelationRepository.java +++ b/addons/common/persistence/jdbc/src/main/java/org/kie/kogito/persistence/jdbc/correlation/JDBCCorrelationRepository.java @@ -34,9 +34,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.module.SimpleModule; -public class PostgreSQLCorrelationRepository { +public class JDBCCorrelationRepository { - static final String INSERT = "INSERT INTO correlation_instances (id, encoded_correlation_id, correlated_id, correlation) VALUES (?, ?, ?, ?::json)"; + static final String INSERT = "INSERT INTO correlation_instances (id, encoded_correlation_id, correlated_id, correlation) VALUES (?, ?, ?, ?)"; static final String DELETE = "DELETE FROM correlation_instances WHERE encoded_correlation_id = ?"; private static final String FIND_BY_ENCODED_ID = "SELECT correlated_id, correlation FROM correlation_instances WHERE encoded_correlation_id = ?"; private static final String FIND_BY_CORRELATED_ID = "SELECT encoded_correlation_id, correlation FROM correlation_instances WHERE correlated_id = ?"; @@ -44,7 +44,7 @@ public class PostgreSQLCorrelationRepository { private DataSource dataSource; private ObjectMapper objectMapper; - public PostgreSQLCorrelationRepository(DataSource dataSource) { + public JDBCCorrelationRepository(DataSource dataSource) { this.dataSource = dataSource; this.objectMapper = ObjectMapperFactory.get().copy(); diff --git a/addons/common/persistence/jdbc/src/main/java/org/kie/kogito/persistence/jdbc/correlation/PostgreSQLCorrelationService.java b/addons/common/persistence/jdbc/src/main/java/org/kie/kogito/persistence/jdbc/correlation/JDBCCorrelationService.java similarity index 89% rename from addons/common/persistence/jdbc/src/main/java/org/kie/kogito/persistence/jdbc/correlation/PostgreSQLCorrelationService.java rename to addons/common/persistence/jdbc/src/main/java/org/kie/kogito/persistence/jdbc/correlation/JDBCCorrelationService.java index d4eba667200..d3624064f8a 100644 --- a/addons/common/persistence/jdbc/src/main/java/org/kie/kogito/persistence/jdbc/correlation/PostgreSQLCorrelationService.java +++ b/addons/common/persistence/jdbc/src/main/java/org/kie/kogito/persistence/jdbc/correlation/JDBCCorrelationService.java @@ -28,13 +28,13 @@ import org.kie.kogito.correlation.CorrelationService; import org.kie.kogito.event.correlation.MD5CorrelationEncoder; -public class PostgreSQLCorrelationService implements CorrelationService { +public class JDBCCorrelationService implements CorrelationService { - private PostgreSQLCorrelationRepository repository; + private JDBCCorrelationRepository repository; private CorrelationEncoder correlationEncoder; - public PostgreSQLCorrelationService(DataSource dataSource) { - this.repository = new PostgreSQLCorrelationRepository(dataSource); + public JDBCCorrelationService(DataSource dataSource) { + this.repository = new JDBCCorrelationRepository(dataSource); this.correlationEncoder = new MD5CorrelationEncoder(); } diff --git a/addons/common/persistence/jdbc/src/main/resources/db/ansi/V1.35.0__create_runtime_ansi.sql b/addons/common/persistence/jdbc/src/main/resources/db/ansi/V1.35.0__create_runtime_ansi.sql index c8c2f02afd2..2868565c5ea 100644 --- a/addons/common/persistence/jdbc/src/main/resources/db/ansi/V1.35.0__create_runtime_ansi.sql +++ b/addons/common/persistence/jdbc/src/main/resources/db/ansi/V1.35.0__create_runtime_ansi.sql @@ -1,10 +1,10 @@ CREATE TABLE process_instances ( - id CHAR(36) NOT NULL, - payload BLOB NOT NULL, - process_id VARCHAR(4000) NOT NULL, - version BIGINT(19), - process_version VARCHAR(4000), + id character(36) NOT NULL, + payload varbinary(1000000) NOT NULL, + process_id character varying(4000) NOT NULL, + version bigint, + process_version character varying(4000), CONSTRAINT process_instances_pkey PRIMARY KEY (id) ); CREATE INDEX idx_process_instances_process_id ON process_instances (process_id, id, process_version); diff --git a/addons/common/persistence/jdbc/src/main/resources/db/ansi/V10.0.1__create_correlation_ansi.sql b/addons/common/persistence/jdbc/src/main/resources/db/ansi/V10.0.1__create_correlation_ansi.sql new file mode 100644 index 00000000000..14adf0fab3a --- /dev/null +++ b/addons/common/persistence/jdbc/src/main/resources/db/ansi/V10.0.1__create_correlation_ansi.sql @@ -0,0 +1,9 @@ +CREATE TABLE correlation_instances +( + id character(36) NOT NULL, + encoded_correlation_id character varying(36) NOT NULL UNIQUE, + correlated_id character varying(36) NOT NULL, + correlation character varying(8000) NOT NULL, + version bigint, + CONSTRAINT correlation_instances_pkey PRIMARY KEY (id) +); \ No newline at end of file diff --git a/addons/common/persistence/jdbc/src/main/resources/db/postgresql/V10.0.1__alter_correlation_PostgreSQL.sql b/addons/common/persistence/jdbc/src/main/resources/db/postgresql/V10.0.1__alter_correlation_PostgreSQL.sql new file mode 100644 index 00000000000..e7b60997a17 --- /dev/null +++ b/addons/common/persistence/jdbc/src/main/resources/db/postgresql/V10.0.1__alter_correlation_PostgreSQL.sql @@ -0,0 +1,2 @@ +ALTER TABLE correlation_instances +ALTER COLUMN correlation TYPE character varying; diff --git a/addons/common/persistence/jdbc/src/test/java/org/kie/persistence/jdbc/correlation/JDBCCorrelationServiceIT.java b/addons/common/persistence/jdbc/src/test/java/org/kie/persistence/jdbc/correlation/JDBCCorrelationServiceIT.java index f374bf8dad1..62212ac0eb0 100644 --- a/addons/common/persistence/jdbc/src/test/java/org/kie/persistence/jdbc/correlation/JDBCCorrelationServiceIT.java +++ b/addons/common/persistence/jdbc/src/test/java/org/kie/persistence/jdbc/correlation/JDBCCorrelationServiceIT.java @@ -27,7 +27,7 @@ import org.kie.kogito.correlation.CompositeCorrelation; import org.kie.kogito.correlation.CorrelationInstance; import org.kie.kogito.correlation.SimpleCorrelation; -import org.kie.kogito.persistence.jdbc.correlation.PostgreSQLCorrelationService; +import org.kie.kogito.persistence.jdbc.correlation.JDBCCorrelationService; import org.kie.kogito.testcontainers.KogitoPostgreSqlContainer; import org.postgresql.ds.PGSimpleDataSource; import org.testcontainers.containers.JdbcDatabaseContainer; @@ -42,7 +42,7 @@ public class JDBCCorrelationServiceIT { @Container private static final KogitoPostgreSqlContainer PG_CONTAINER = new KogitoPostgreSqlContainer(); private static PGSimpleDataSource dataSource; - private static PostgreSQLCorrelationService correlationService; + private static JDBCCorrelationService correlationService; @BeforeAll public static void setUp() { @@ -50,7 +50,7 @@ public static void setUp() { dataSource.setUrl(PG_CONTAINER.getJdbcUrl()); dataSource.setUser(PG_CONTAINER.getUsername()); dataSource.setPassword(PG_CONTAINER.getPassword()); - correlationService = new PostgreSQLCorrelationService(dataSource); + correlationService = new JDBCCorrelationService(dataSource); //create table // DDLRunner.init(new GenericRepository(dataSource), true); initMigration(PG_CONTAINER, "postgresql"); diff --git a/quarkus/addons/persistence/jdbc/runtime/src/main/java/org/kie/kogito/persistence/quarkus/JDBCorrelationServiceProducer.java b/quarkus/addons/persistence/jdbc/runtime/src/main/java/org/kie/kogito/persistence/quarkus/JDBCorrelationServiceProducer.java index a2bbcbf0a55..f60c26c3911 100644 --- a/quarkus/addons/persistence/jdbc/runtime/src/main/java/org/kie/kogito/persistence/quarkus/JDBCorrelationServiceProducer.java +++ b/quarkus/addons/persistence/jdbc/runtime/src/main/java/org/kie/kogito/persistence/quarkus/JDBCorrelationServiceProducer.java @@ -18,29 +18,17 @@ */ package org.kie.kogito.persistence.quarkus; -import java.util.Optional; - import javax.sql.DataSource; -import org.eclipse.microprofile.config.inject.ConfigProperty; import org.kie.kogito.correlation.CorrelationService; -import org.kie.kogito.event.correlation.DefaultCorrelationService; -import org.kie.kogito.persistence.jdbc.correlation.PostgreSQLCorrelationService; +import org.kie.kogito.persistence.jdbc.correlation.JDBCCorrelationService; import jakarta.enterprise.inject.Produces; -import jakarta.inject.Inject; - -import static org.kie.kogito.persistence.quarkus.KogitoAddOnPersistenceJDBCConfigSourceFactory.DATASOURCE_DB_KIND; -import static org.kie.kogito.persistence.quarkus.KogitoAddOnPersistenceJDBCConfigSourceFactory.POSTGRESQL; public class JDBCorrelationServiceProducer { - @Inject - @ConfigProperty(name = DATASOURCE_DB_KIND) - Optional dbKind; - @Produces public CorrelationService jdbcCorrelationService(DataSource dataSource) { - return dbKind.filter(POSTGRESQL::equals).isPresent() ? new PostgreSQLCorrelationService(dataSource) : new DefaultCorrelationService(); + return new JDBCCorrelationService(dataSource); } }