Skip to content

Commit b79694d

Browse files
committed
Use H2 for JBatch tests instead of Derby
so that we don't need to manage more dependencies
1 parent e399b74 commit b79694d

File tree

6 files changed

+75
-27
lines changed

6 files changed

+75
-27
lines changed

.github/dependabot.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ updates:
5353
- "com.puppycrawl.tools:*"
5454
# DB drivers:
5555
- "com.h2database:h2"
56-
- "org.apache.derby:derby"
5756
- "org.postgresql:postgresql"
5857
- "org.mariadb.jdbc:mariadb-java-client"
5958
- "com.mysql:mysql-connector-j"
@@ -111,10 +110,6 @@ updates:
111110
# we don't want always want to get the latest Weld version:
112111
- dependency-name: "org.jboss.weld.se:*"
113112
update-types: ["version-update:semver-major"]
114-
# Sticking to Derby 10.16 for now since later versions require JDK 21+, and we need to test with JDK 17.
115-
# See https://db.apache.org/derby/derby_downloads.html
116-
- dependency-name: "org.apache.derby:*"
117-
update-types: [ "version-update:semver-major", "version-update:semver-minor" ]
118113
# Sticking to SLF4J 1.x for now since later versions require to upgrade providers
119114
# (Log4j, ... see https://www.slf4j.org/faq.html#changesInVersion200),
120115
# and also because we only need this dependency for AWS SDK,

build/parents/build/pom.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,6 @@
158158

159159
<!-- >>> JDBC Drivers -->
160160
<version.com.h2database>2.3.232</version.com.h2database>
161-
<!-- Sticking to Derby 10.16 for now since later versions require JDK 21+, and we need to test with JDK 17.
162-
See https://db.apache.org/derby/derby_downloads.html -->
163-
<version.org.apache.derby>10.16.1.1</version.org.apache.derby>
164161
<version.org.postgresql>42.7.7</version.org.postgresql>
165162
<version.org.mariadb.jdbc>3.5.3</version.org.mariadb.jdbc>
166163
<version.mysql.mysql-connector-j>9.3.0</version.mysql.mysql-connector-j>
@@ -879,11 +876,6 @@
879876
<artifactId>h2</artifactId>
880877
<version>${version.com.h2database}</version>
881878
</dependency>
882-
<dependency>
883-
<groupId>org.apache.derby</groupId>
884-
<artifactId>derby</artifactId>
885-
<version>${version.org.apache.derby}</version>
886-
</dependency>
887879
<dependency>
888880
<groupId>org.postgresql</groupId>
889881
<artifactId>postgresql</artifactId>

pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@
209209
<!-- The lowest supported version of Java for applications using Hibernate Search -->
210210
<!-- Set statically, independently from the current JDK: we want our code to comply with this version -->
211211
<!-- Adjust the contributing guide when changing the release Java version -->
212-
<!-- Once upgrading review the dependency list to see if any major versions can be updated e.g. Derby 10.17 requires JDK 21 (see dependabot config and comments in POMs). -->
213212
<java-version.main.release>17</java-version.main.release>
214213
<java-version.main.compiler.java_home>${java.home}</java-version.main.compiler.java_home>
215214
<java-version.main.compiler>${java-version.main.compiler.java_home}/bin/javac</java-version.main.compiler>

util/internal/integrationtest/jbatch-runtime/pom.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@
3535
<scope>compile</scope>
3636
</dependency>
3737
<!--
38-
JBatch requires a database in order to work, and it seems it uses SQL that won't work with H2.
39-
Anyway, it uses an embedded Derby instance by default, so we just put the Derby driver in the classpath
40-
so it won't complain.
38+
JBatch requires a database in order to work. Since we either need to use an embedded Derby or create the schema,
39+
we want to keep the setup to a minimum and use only H2.
40+
Derby is not used to keep the # of managed dependencies lower.
4141
-->
4242
<dependency>
43-
<groupId>org.apache.derby</groupId>
44-
<artifactId>derby</artifactId>
45-
<version>${version.org.apache.derby}</version>
43+
<groupId>com.h2database</groupId>
44+
<artifactId>h2</artifactId>
45+
<version>${version.com.h2database}</version>
4646
<scope>compile</scope>
4747
</dependency>
4848
</dependencies>
Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
# SPDX-License-Identifier: Apache-2.0
22
# Copyright Red Hat Inc. and Hibernate Authors
33

4-
# Let JBatch use an embedded Derby database (the default),
5-
# since the SQL it generates doesn't seem to work on other DBs (H2 in particular)
4+
# Configure h2 in-memory database to be used with JBatch,
5+
# It requires the user and password to be passed via the following properties.
6+
# See com.ibm.jbatch.container.util.BatchContainerConstants for other property constants:
7+
DB_USER=sa
8+
DB_PWD=sa
69

7-
# However, we still customize the database location
8-
# (the default uses a "RUNTIMEDB" directory in the current working directory)
9-
JDBC_URL=jdbc:derby:memory:jbatch;create=true
10+
# Since we are not relying on the embedded Derby instance, we have to manually create the schema.
11+
# To do that, the init script is included in the JDBC url.
12+
# Schema scripts are adapted from the built-in Derby ones located in com.ibm.jbatch.container.services.impl.JDBCPersistenceManagerSQLConstants
13+
# H2 Database Configuration
14+
JDBC_URL=jdbc:h2:mem:db1;INIT=RUNSCRIPT FROM 'classpath:/h2-batch-schema.sql';DB_CLOSE_DELAY=-1
1015
# Need to explicitly specify the driver class since the default ones points to `org.apache.derby.jdbc.EmbeddedDriver`
11-
# which is not there anymore since Derby 10.15
12-
JDBC_DRIVER=org.apache.derby.iapi.jdbc.AutoloadedDriver
16+
JDBC_DRIVER=org.h2.Driver
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
CREATE SCHEMA IF NOT EXISTS JBATCH;
2+
SET SCHEMA JBATCH;
3+
CREATE TABLE IF NOT EXISTS JOBINSTANCEDATA
4+
(
5+
jobinstanceid BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1) PRIMARY KEY,
6+
name VARCHAR(512),
7+
apptag VARCHAR(512)
8+
);
9+
CREATE TABLE IF NOT EXISTS EXECUTIONINSTANCEDATA
10+
(
11+
jobexecid BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1) PRIMARY KEY,
12+
jobinstanceid BIGINT,
13+
createtime TIMESTAMP,
14+
starttime TIMESTAMP,
15+
endtime TIMESTAMP,
16+
updatetime TIMESTAMP,
17+
parameters BLOB,
18+
batchstatus VARCHAR(512),
19+
exitstatus VARCHAR(512),
20+
CONSTRAINT JOBINST_JOBEXEC_FK FOREIGN KEY (jobinstanceid) REFERENCES JOBINSTANCEDATA (jobinstanceid) ON DELETE CASCADE
21+
);
22+
CREATE TABLE IF NOT EXISTS STEPEXECUTIONINSTANCEDATA
23+
(
24+
stepexecid BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1) PRIMARY KEY,
25+
jobexecid BIGINT,
26+
batchstatus VARCHAR(512),
27+
exitstatus VARCHAR(512),
28+
stepname VARCHAR(512),
29+
readcount INTEGER,
30+
writecount INTEGER,
31+
commitcount INTEGER,
32+
rollbackcount INTEGER,
33+
readskipcount INTEGER,
34+
processskipcount INTEGER,
35+
filtercount INTEGER,
36+
writeskipcount INTEGER,
37+
startTime TIMESTAMP,
38+
endTime TIMESTAMP,
39+
persistentData BLOB,
40+
CONSTRAINT JOBEXEC_STEPEXEC_FK FOREIGN KEY (jobexecid) REFERENCES EXECUTIONINSTANCEDATA (jobexecid) ON DELETE CASCADE
41+
);
42+
CREATE TABLE IF NOT EXISTS JOBSTATUS
43+
(
44+
id BIGINT PRIMARY KEY,
45+
obj BLOB,
46+
CONSTRAINT JOBSTATUS_JOBINST_FK FOREIGN KEY (id) REFERENCES JOBINSTANCEDATA (jobinstanceid) ON DELETE CASCADE
47+
);
48+
CREATE TABLE IF NOT EXISTS STEPSTATUS
49+
(
50+
id BIGINT PRIMARY KEY,
51+
obj BLOB,
52+
CONSTRAINT STEPSTATUS_STEPEXEC_FK FOREIGN KEY (id) REFERENCES STEPEXECUTIONINSTANCEDATA (stepexecid) ON DELETE CASCADE
53+
);
54+
CREATE TABLE IF NOT EXISTS CHECKPOINTDATA
55+
(
56+
id VARCHAR(512),
57+
obj BLOB
58+
);

0 commit comments

Comments
 (0)