Skip to content

Commit

Permalink
Renamed jBatch SQL table names
Browse files Browse the repository at this point in the history
Signed-off-by: coduz <alberto.codutti@eurotech.com>
  • Loading branch information
Coduz committed Mar 21, 2020
1 parent 57a9ea3 commit 05bc414
Show file tree
Hide file tree
Showing 11 changed files with 100 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@
import javax.persistence.Table;

@Entity(name = "CheckpointData")
@Table(name = "CHECKPOINTDATA")
@Table(name = "jbtc_checkpoint_data")
public class JpaCheckpointData extends AbstractJpaJbatchEntity {

@Column(name = "jobinstanceid")
private long jobInstanceId;

@Id
@Column(name = "id", updatable = false, nullable = false)
private String id;
Expand All @@ -34,6 +37,14 @@ public class JpaCheckpointData extends AbstractJpaJbatchEntity {
public JpaCheckpointData() {
}

public long getJobInstanceId() {
return jobInstanceId;
}

public void setJobInstanceId(long jobInstanceId) {
this.jobInstanceId = jobInstanceId;
}

public String getId() {
return id;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ private JpaCheckpointDataDAO() {
public static JpaCheckpointData create(EntityManager em, CheckpointDataKey checkpointDataKey, CheckpointData checkpointData) {

JpaCheckpointData jpaCheckpointData = new JpaCheckpointData();
jpaCheckpointData.setJobInstanceId(checkpointDataKey.getJobInstanceId());
jpaCheckpointData.setId(checkpointDataKey.getCommaSeparatedKey());
jpaCheckpointData.setObj(checkpointData);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import java.util.Properties;

@Entity(name = "ExecutionInstanceData")
@Table(name = "EXECUTIONINSTANCEDATA")
@Table(name = "jbtc_execution_instance_data")
@NamedQueries({
@NamedQuery(name = "ExecutionInstanceData.getByJobInstance",
query = "SELECT eid FROM ExecutionInstanceData eid WHERE eid.jobInstanceId = :jobInstanceId ORDER BY eid.createTime DESC"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import java.io.Serializable;

@Entity(name = "JobInstanceData")
@Table(name = "JOBINSTANCEDATA")
@Table(name = "jbtc_job_instance_data")
@NamedQueries({
@NamedQuery(name = "JobInstanceData.selectByName",
query = "SELECT DISTINCT(jid) FROM JobInstanceData jid WHERE jid.name NOT LIKE :name"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
*******************************************************************************/
package org.eclipse.kapua.job.engine.jbatch.persistence.jpa;

import com.ibm.jbatch.container.exception.PersistenceException;
import com.ibm.jbatch.container.impl.PartitionedStepBuilder;
import org.eclipse.kapua.commons.jpa.EntityManager;

Expand All @@ -26,20 +25,17 @@ private JpaJobInstanceDataDAO() {
}

public static JpaJobInstanceData create(EntityManager em, String name, String appTag, String jobXml) {
try {
JpaJobInstanceData jpaJobInstanceData = new JpaJobInstanceData();
jpaJobInstanceData.setName(name);
jpaJobInstanceData.setAppTag(appTag);
jpaJobInstanceData.setJobXml(jobXml);

em.persist(jpaJobInstanceData);
em.flush();
em.refresh(jpaJobInstanceData);

return jpaJobInstanceData;
} catch (Exception e) {
throw new PersistenceException(e);
}

JpaJobInstanceData jpaJobInstanceData = new JpaJobInstanceData();
jpaJobInstanceData.setName(name);
jpaJobInstanceData.setAppTag(appTag);
jpaJobInstanceData.setJobXml(jobXml);

em.persist(jpaJobInstanceData);
em.flush();
em.refresh(jpaJobInstanceData);

return jpaJobInstanceData;
}

public static JpaJobInstanceData find(EntityManager em, long id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import javax.persistence.Table;

@Entity(name = "JobStatus")
@Table(name = "JOBSTATUS")
@Table(name = "jbtc_job_status")
public class JpaJobStatus extends AbstractJpaJbatchEntity {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import java.util.Date;

@Entity(name = "StepExecutionInstanceData")
@Table(name = "STEPEXECUTIONINSTANCEDATA")
@Table(name = "jbtc_step_execution_instance_data")
@NamedQueries({
@NamedQuery(name = "StepExecutionInstanceData.selectByJobExecId",
query = "SELECT seid FROM StepExecutionInstanceData seid WHERE seid.jobExecutionId = :jobExecutionId"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import javax.persistence.Table;

@Entity(name = "StepStatus")
@Table(name = "STEPSTATUS")
@Table(name = "jbtc_step_status")
@NamedQueries({
@NamedQuery(name = "StepStatus.findByJobInstanceIdStepName",
query = "SELECT ss " +
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2019 Eurotech and/or its affiliates and others
Copyright (c) 2019, 2020 Eurotech and/or its affiliates and others
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -19,4 +19,7 @@
<include relativeToChangelogFile="true" file="./job-engine-jbatch-timestamp.xml"/>
<include relativeToChangelogFile="true" file="./queued_job-timestamp.xml"/>

</databaseChangeLog>
<include relativeToChangelogFile="true" file="./job_engine_jbatch-rename_tables.xml"/>
<include relativeToChangelogFile="true" file="./checkpoint_data-add_column_jobinstanceid.xml"/>

</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2020 Eurotech and/or its affiliates and others
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
Contributors:
Eurotech - initial API and implementation
-->
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd"

logicalFilePath="KapuaDB/changelog-job-engine-jbatch-1.2.0.xml">

<include relativeToChangelogFile="true" file="../common-properties.xml"/>

<changeSet id="changelog-job-engine-jbatch-1.2.0_add_column_jobinstanceid" author="eurotech">
<addColumn tableName="jbtc_checkpoint_data">
<column name="jobinstanceid" type="bigint"/>
</addColumn>

<addForeignKeyConstraint constraintName="fk_checkpointdata_jobinstanceid"
baseTableName="jbtc_checkpoint_data"
baseColumnNames="jobinstanceid"
referencedTableName="jbtc_job_instance_data"
referencedColumnNames="jobinstanceid"
onDelete="CASCADE"/>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2020 Eurotech and/or its affiliates and others
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
Contributors:
Eurotech - initial API and implementation
-->
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd"

logicalFilePath="KapuaDB/changelog-job-engine-jbatch-1.2.0.xml">

<include relativeToChangelogFile="true" file="../common-properties.xml"/>

<changeSet id="changelog-job-engine-jbatch-1.2.0_renameTable" author="eurotech">
<renameTable oldTableName="checkpointdata" newTableName="jbtc_checkpoint_data"/>
<renameTable oldTableName="executioninstancedata" newTableName="jbtc_execution_instance_data"/>
<renameTable oldTableName="jobinstancedata" newTableName="jbtc_job_instance_data"/>
<renameTable oldTableName="jobstatus" newTableName="jbtc_job_status"/>
<renameTable oldTableName="stepexecutioninstancedata" newTableName="jbtc_step_execution_instance_data"/>
<renameTable oldTableName="stepstatus" newTableName="jbtc_step_status"/>
</changeSet>
</databaseChangeLog>

0 comments on commit 05bc414

Please sign in to comment.